
Enter a search term above to see results...
Enter a search term above to see results...
Scheduler
is a core class in Semantic UI’s reactivity system that manages the scheduling and execution of reactive computations. It handles the queueing and flushing of reactions, ensuring efficient updates when reactive dependencies change.
The Scheduler class is responsible for:
Advanced Use Only - Scheduler is primarily used internally by
Signal
andReaction
. Most developers should not need to interact with it directly unless building advanced reactive systems or meta-frameworks.
The currently executing reaction.
Scheduler.current
Reaction | null - The currently executing reaction, or null if no reaction is executing.
import { Scheduler } from '@semantic-ui/reactivity';
console.log(Scheduler.current); // null if outside a reaction
Set of reactions waiting to be executed.
Scheduler.pendingReactions
Set - The set of pending reactions.
Schedules a reaction to be executed during the next flush cycle.
Scheduler.scheduleReaction(reaction)
Name | Type | Description |
---|---|---|
reaction | Reaction | The reaction to schedule for execution |
import { Scheduler, Reaction } from '@semantic-ui/reactivity';
const reaction = Reaction.create(() => { console.log('Reaction executed');});
Scheduler.scheduleReaction(reaction);
Schedules a flush of all pending reactions using the microtask queue.
Scheduler.scheduleFlush()
import { Scheduler } from '@semantic-ui/reactivity';
Scheduler.scheduleFlush();
Immediately executes all pending reactions and afterFlush callbacks.
Scheduler.flush()
import { Scheduler } from '@semantic-ui/reactivity';
Scheduler.flush(); // Executes all pending reactions immediately
Registers a callback to be executed after the next flush cycle completes.
Scheduler.afterFlush(callback)
Name | Type | Description |
---|---|---|
callback | Function | Function to execute after flush completes |
import { Scheduler } from '@semantic-ui/reactivity';
Scheduler.afterFlush(() => { console.log('Flush completed');});
Returns the stack trace of the current reaction for debugging purposes.
Scheduler.getSource()
string | undefined - The stack trace of the current reaction, or undefined if no reaction is running.
import { Scheduler, Reaction } from '@semantic-ui/reactivity';
Reaction.create(() => { console.log(Scheduler.getSource());});