Callbacks are invoked in a new task (similar to setTimeout(cb, 0)
).
This is the default behavior.
As a consequence, synchronous code and resolved promise executions that immediately follow the original change (which triggered the callback) will have been executed already when the callback runs.
Callbacks are invoked synchronously, either immediately or after the current batch()
.
For example:
emit(myObject.click, { x: 1, y: 2 });; // sync callbacks run here
or
batch(() => {
// ...
mySignal.value = newValue;
}); // Or here, when the outermost batch is complete.
Controls when callbacks are executed.