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

[prefer-destructured-store-props]: Allow methods? #912

Closed
marekdedic opened this issue Nov 11, 2024 · 7 comments
Closed

[prefer-destructured-store-props]: Allow methods? #912

marekdedic opened this issue Nov 11, 2024 · 7 comments
Labels
enhancement New feature or request store

Comments

@marekdedic
Copy link
Contributor

marekdedic commented Nov 11, 2024

Description

Hi,
I have a reactive map in a store (its a SvelteMap) and I am not really sure that's the correct way to do this. However, that's a little off topic. The thing is, the prefer-destructured-store-props rule is complaining when I use the get() method and I think that's a false positive?

It seems to me like methods should be allowed without destructuring. I am not an expert in reactivity in svelte, so I am not sure, though... What do you think?

@marekdedic marekdedic added the enhancement New feature or request label Nov 11, 2024
@mikededo
Copy link
Contributor

Would it be possible to have a repro or an example?

@marekdedic
Copy link
Contributor Author

Here you go :)

@ota-meshi
Copy link
Member

I have a reactive map in a store (its a SvelteMap) and I am not really sure that's the correct way to do this.

Hmm. I'm not sure if the user needs to wrap a SvelteMap in a store 🤔.
Shouldn't they just use a SvelteMap instance?

I don't think the rule is currently giving a false positive.

@marekdedic
Copy link
Contributor Author

Honestly, I don't know -> sveltejs/svelte#14376

@marekdedic
Copy link
Contributor Author

Ok, I resolved the linked discussion and you should indeed not use svelte/reactivity together with stores.

However, I am thinking my original issue still stands - the prefer-destructured-store-props rule is intended to prevent unneeded redraws when only some object properties change as fa as I understand it. However, when you call a function on something in a store, this probably doesn't apply? I mean you probably want a redraw every time the store changes because who knows what the function is doing?

@baseballyama
Copy link
Member

Can you share some example code?

@marekdedic
Copy link
Contributor Author

Hmm, I tried putting a class inside a store, but that doesn't really make sense as anything the class returns from its methods won't be reactive... So this probably isn't useful after all, sorry!

@marekdedic marekdedic closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request store
Projects
None yet
Development

No branches or pull requests

4 participants