Deferred Updates Queue Flush Timing Relative to Synchronous DOM Reads
0 reputation · 02 Dec 2021, 06:37 UTC
Deferred Updates Queue Flush Timing Relative to Synchronous DOM Reads
When ko.options.deferUpdates is enabled, Knockout coalesces observable notifications into an internal task queue. The objective is to establish whether a synchronous DOM read immediately after an observable mutation observes the state before or after the queue flushes.
The documentation does not define a strict ordering guarantee between deferred notification processing and synchronous DOM reads or writes. The internal scheduler is not part of the public API, so application code cannot force an early flush, and behavior for computed observables without active subscribers may vary by Knockout version.
Is the deferred queue guaranteed to flush before the next synchronous DOM access? Does a subscriber-less computed re-evaluate during the deferred flush, or only when a new subscriber attaches?