UNPKG

kr-observable

Version:
17 lines (16 loc) 421 B
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; } }