Preprocessor candidate
FluffyDiscord opened this issue · 1 comments
FluffyDiscord commented
This library seems interesting as it solves the one thing that is currently really missing from svelte stores.
I think the whole .zoom() could be transformed into basic dot style accessors using svelte.preprocess and get rid of additional code - make it Svelte-y.
Eg. this
<script>
const store = writtableTree({
user: {
email: "u@mail.com",
messages: []
}
})
const user = store.zoom("user")
const userEmail = user.zoom("email")
</script>
<span>{$userEmail}</span>could be hidden behind preprocessor, as we would simply use this
<script>
const store = writtableTree({
user: {
email: "u@mail.com",
messages: []
}
})
</script>
<span>{$store.user.email}</span>And you would still get the benefits from your library.
So when I would set a value in Svelte component, it would notify whole tree.
// would notify email, user and store itself
$store.user.email = "changed@mail.com"
// just like this would
$userEmail = "changed@mail.com"igrep commented
Interesting idea. Pull request welcome!