track(() => storeOrSignal)
should track the store or signal
#21
Replies: 2 comments
-
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.
-
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(() => signal
should returnsignal
, for backwards compatibility.Code examples
Links / References
No response
Beta Was this translation helpful? Give feedback.
All reactions