-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat: $state.eager(value)
#16849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+181
−3
Merged
feat: $state.eager(value)
#16849
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
21811b1
WIP implement `$effect.pending(...)`
Rich-Harris f38319a
Merge branch 'main' into effect-pending-value
dummdidumm d8e61f6
feat: `$state.eager(value)` (#16926)
dummdidumm 7c0fef4
merge
Rich-Harris 4fa2be6
decouple from boundaries
Rich-Harris 6987668
use queue_micro_task
Rich-Harris de99449
add test
Rich-Harris 45e350f
Merge branch 'main' into effect-pending-value
Rich-Harris 61ce182
Merge branch 'effect-pending-value' of https://github.com/sveltejs/sv…
Rich-Harris 05c9196
fix
Rich-Harris 6949e92
changeset
Rich-Harris 8ac29e4
revert
Rich-Harris 5bfc484
tidy up
Rich-Harris f8c7b17
update docs
Rich-Harris 2e5c15f
Merge branch 'main' into effect-pending-value
Rich-Harris f667787
Update packages/svelte/src/internal/client/reactivity/batch.js
Rich-Harris 2b59618
minor tweak
Rich-Harris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'svelte': minor | ||
| --- | ||
|
|
||
| feat: add `$state.eager(value)` rune |
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
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
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
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
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
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
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
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
36 changes: 36 additions & 0 deletions
36
packages/svelte/tests/runtime-runes/samples/async-state-eager/_config.js
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import { tick } from 'svelte'; | ||
| import { test } from '../../test'; | ||
|
|
||
| export default test({ | ||
| async test({ assert, target }) { | ||
| const [count, shift] = target.querySelectorAll('button'); | ||
|
|
||
| shift.click(); | ||
| await tick(); | ||
| assert.htmlEqual(target.innerHTML, `<button>0</button><button>shift</button><p>0</p>`); | ||
|
|
||
| count.click(); | ||
| await tick(); | ||
| assert.htmlEqual(target.innerHTML, `<button>1</button><button>shift</button><p>0</p>`); | ||
|
|
||
| count.click(); | ||
| await tick(); | ||
| assert.htmlEqual(target.innerHTML, `<button>2</button><button>shift</button><p>0</p>`); | ||
|
|
||
| count.click(); | ||
| await tick(); | ||
| assert.htmlEqual(target.innerHTML, `<button>3</button><button>shift</button><p>0</p>`); | ||
|
|
||
| shift.click(); | ||
| await tick(); | ||
| assert.htmlEqual(target.innerHTML, `<button>3</button><button>shift</button><p>1</p>`); | ||
|
|
||
| shift.click(); | ||
| await tick(); | ||
| assert.htmlEqual(target.innerHTML, `<button>3</button><button>shift</button><p>2</p>`); | ||
|
|
||
| shift.click(); | ||
| await tick(); | ||
| assert.htmlEqual(target.innerHTML, `<button>3</button><button>shift</button><p>3</p>`); | ||
| } | ||
| }); |
20 changes: 20 additions & 0 deletions
20
packages/svelte/tests/runtime-runes/samples/async-state-eager/main.svelte
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <script> | ||
| let count = $state(0); | ||
|
|
||
| let resolvers = []; | ||
|
|
||
| function push(value) { | ||
| const { promise, resolve } = Promise.withResolvers(); | ||
| resolvers.push(() => resolve(value)); | ||
| return promise; | ||
| } | ||
| </script> | ||
|
|
||
| <button onclick={() => count += 1}>{$state.eager(count)}</button> | ||
| <button onclick={() => resolvers.shift()?.()}>shift</button> | ||
|
|
||
| <svelte:boundary> | ||
| <p>{await push(count)}</p> | ||
|
|
||
| {#snippet pending()}{/snippet} | ||
| </svelte:boundary> |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.