kr-observable
Version:
Adds reactivity power for your JavaScript
17 lines (16 loc) • 421 B
JavaScript
export class Notifier {
static queued = false;
static runId = 2;
static notify(runnable, changes) {
runnable.runId = this.runId;
runnable.subscriber(changes);
if (this.queued)
return;
this.queued = true;
queueMicrotask(this.flush);
}
static flush() {
Notifier.queued = false;
Notifier.runId = (Notifier.runId + 1) % 100_000;
}
}