Replies: 6 comments
-
Yeah I am thinking about this too! |
Beta Was this translation helpful? Give feedback.
-
An option for this would be really nice, yes. |
Beta Was this translation helpful? Give feedback.
-
It's a nice pattern to have. What would be the name of an option that reset the state of a Signal that is no more subscribed to? Riverpod use the term AutoDisposable which is clear but hidden in the codegen most of the time. But what's the term in TS, Preact, react or other solution and how do they decide to expose it? |
Beta Was this translation helpful? Give feedback.
-
Would definitely be very useful feature to have. |
Beta Was this translation helpful? Give feedback.
-
Could I request some example use cases to test against here? |
Beta Was this translation helpful? Give feedback.
-
Latest version adds a dispose method that will reset to initial value. This does not happen when there are no more listeners, but you can call the method at any time. It will also unsubscribe from any effects. I didn't add the auto dispose yet because i think there still might be cases where you want a signal with a value without listeners. For example effects are optional and you can still work with them outside of an effect |
Beta Was this translation helpful? Give feedback.
-
@rodydavis I was thinking about how riverpod handles this and whether signals should have the same behavior. It could also be configurable with an optional
keepAlive
argument;dispose
would meanreset
in this context.Beta Was this translation helpful? Give feedback.
All reactions