lint plugin should complain when writing track(() => storeOrSignal)
#21
Replies: 4 comments 1 reply
-
|
Thanks @wmertens ! We've just reviewed this and these were the conclusions;
WDYT? |
Beta Was this translation helpful? Give feedback.
-
|
@shairez no, when you return a Signal it should subscribe to the Signal. When you return a Store it should subscribe to the Store, meaning it will get called when the store is mutated (store.foo=1) but not when the children are mutated (store.foo.bar=1). It should not descend into children. If you return store.sig, you're returning a signal, not a store. |
Beta Was this translation helpful? Give feedback.
-
|
I think you are saying that My issue is that it is confusing: I believe this behavior is a foot gun, and i would rather just not allow the shortcut as it will have surprising behavior. |
Beta Was this translation helpful? Give feedback.
-
|
After another RFC meeting we decided to go with the lint rule for this. waiting for a champion to lead this. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What is it about?
No response
What's the motivation for this proposal?
Problems you are trying to solve:
track(() => signal)instead oftrack(signal)and this doesn't do anythingProposed Solution / Feature
What do you propose?
when the track is given a callback, and the callback returns a signal/store, then that signal or store should be subscribed to.
Note that unlike
track(signal)where it returnssignal.value,track(() => signalshould returnsignal, for backwards compatibility.Code examples
Links / References
No response
Beta Was this translation helpful? Give feedback.
All reactions