-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rework SSR store autosubscription (#5419)
- Loading branch information
Showing
9 changed files
with
193 additions
and
78 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
1 change: 0 additions & 1 deletion
1
test/runtime/samples/reactive-assignment-in-complex-declaration-with-store-2/_config.js
This file contains 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
1 change: 0 additions & 1 deletion
1
test/runtime/samples/reactive-assignment-in-complex-declaration-with-store/_config.js
This file contains 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 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
3 changes: 3 additions & 0 deletions
3
test/runtime/samples/store-auto-resubscribe-immediate/_config.js
This file contains 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,3 @@ | ||
export default { | ||
html: '{"answer":4}' | ||
}; |
31 changes: 31 additions & 0 deletions
31
test/runtime/samples/store-auto-resubscribe-immediate/main.svelte
This file contains 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,31 @@ | ||
<script> | ||
import { writable } from '../../../../store'; | ||
let value = writable({ foo: 1, bar: 2 }); | ||
$value.foo = $value.foo + $value.bar; // 3 | ||
$value.bar = $value.foo * $value.bar; // 6 | ||
// should resubscribe immediately | ||
value = writable({ foo: $value.foo + 2, bar: $value.bar - 2 }); // { foo: 5, bar: 4 } | ||
// should mutate the store value | ||
$value.baz = $value.foo + $value.bar; // { foo: 5, bar: 4, baz: 9 } | ||
// should resubscribe immediately | ||
value = writable({ qux: $value.baz - $value.foo }); // { qux: 4 } | ||
// making sure instrumentation returns the expression value | ||
$value = { | ||
one: writable( | ||
$value = { | ||
two: ({ $value } = { $value: { fred: $value.qux } }) // { fred: 4 } | ||
} // { two: { $value: { fred: 4 } } } | ||
) // { one: { two: { $value: { fred: 4 } } } } | ||
}; | ||
const one = $value.one; | ||
value.update(val => ({ answer: $one.two.$value.fred })); // { answer: 4 } | ||
</script> | ||
|
||
{JSON.stringify($value)} |