Experimental zero cost declarative fine grained reactivity system
Due to lack of drop guarantee in Rust, it can be unsound if the effect is leaked. This is same limitation as scoped task.
It's unsafe to manually poll boxed future containing effects and leaking it. You can't have undefined behaviour by using well defined executors(like tokio or async_std) and future combinators
DependencyTracker: 1 pointer sized main reactive primitive wrapping Intrusive linked list. Which contains start pointer toBindingBinding: Node ofDependencyTracker. Unlinked on drop. Each node contains pointer toEffect's queue nodeEffect: Contains constant number of bindings(Each one for dependingDependencyTracker) and a node which can be linked to a queueQueue: Lazily evaluated effect queue. Evaluate queued effects and provides an asynchronous interface.
DependencyTrackers are created and pinnedEffects are created, pinned, initialized and evaluate the effect closure once- During evaluation, each
Bindings are attached to a correspondingDependencyTracker - When a value changes, corresponding
DependencyTrackeris notified. - Notified
DependencyTrackertraverses linkedBindingnodes, link theEffectnode to theQueueand clear the list Wakerin theQueuenotify upperExecutorwhen nodes are added- On next poll, the
Queuepops first linked node, run effect closure. Repeat until there is no nodes left in the queue
See crates/example-app for more complex example
Note
Number of required bindings are calculated in compile time(using macro).
The project is dual-licensed under Apache-2.0 and MIT.