5 ms·
The key is topological sorting of a dependency graph. This can be done implicitly by storing a reactive variable node’s depth once it is created, and just makin
by wlib 3y ago
The key is topological sorting of a dependency graph. This can be done implicitly by storing a reactive variable node’s depth once it is created, and just making sure that updates are enqueued in separate queues per depth.
I have a somewhat small implementation that transparently batches updates with queueMicrotask in this library (bruh): https://github.com/Technical-Source/bruh/blob/a829af9df9405b906aca07f2dce24f25568b9ff8/packages/bruh/src/reactive/index.mjs#L37 https://github.com/Technical-Source/bruh/blob/a829af9df9405b...