Skip to content
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

Preprocessor candidate #8

Open
FluffyDiscord opened this issue Dec 18, 2022 · 1 comment
Open

Preprocessor candidate #8

FluffyDiscord opened this issue Dec 18, 2022 · 1 comment

Comments

@FluffyDiscord
Copy link

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
Copy link
Owner

igrep commented Dec 20, 2022

Interesting idea. Pull request welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants