Add reactive always, when & bind features#661
Open
scriptogre wants to merge 1 commit intobigskysoftware:devfrom
Open
Add reactive always, when & bind features#661scriptogre wants to merge 1 commit intobigskysoftware:devfrom
always, when & bind features#661scriptogre wants to merge 1 commit intobigskysoftware:devfrom
Conversation
always, when, and bind features
bfdb740 to
76c634c
Compare
always, when, and bind featuresalways, when &bind features
always, when &bind featuresalways, when & bind features
4cd343f to
b7274fc
Compare
b7274fc to
6548ec9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this enables
Three features
alwaysalways put '$' + $total into mewhenwhen $count changes put it into mebindbind .dark and #toggle's checkedalwaysRuns its commands with automatic dependency tracking. When any dependency changes,
the block re-runs top to bottom:
For independent tracking, use separate
alwaysstatements:whenWatches an expression, gives you
it(the new value):bindTwo-way sync. Accepts
and,with, orto. Left side wins on init:How it works
Single
createEffect()primitive. When an effect evaluates, the runtime recordsevery variable, property, and attribute read. When any change, the effect re-runs.
Effects batch via
queueMicrotask, deduplicate withObject.is, and auto-disposewhen the element disconnects.
Tests
89 tests across
when.js(40),bind.js(34),always.js(15).