hookstate icon indicating copy to clipboard operation
hookstate copied to clipboard

How to unsubscribe to a state once we subscribe to it ?

Open nateshmbhat opened this issue 3 years ago • 5 comments
trafficstars

https://hookstate.js.org/docs/extensions-subscribable In the docs page, you mention how to subscribe to state, there is no mention of how to stop subscribing or how to unsubscribe there.

nateshmbhat avatar Sep 01 '22 11:09 nateshmbhat

subscribe function returns a function, which should be called when you want to unsubscribe. Notice useEffect uses the unsubscribe callback returned by the subscribe function.

avkonst avatar Sep 01 '22 11:09 avkonst

Thanks for the clarification ! It would be good if you also mention in the docs that we can monitor for state outside of component by using subscribable plugin directly with hookstate function.

nateshmbhat avatar Sep 01 '22 12:09 nateshmbhat

this is assumed that global state has access to the same extensions as the locally created state... but ok, I will mention it..

avkonst avatar Sep 01 '22 12:09 avkonst

Hey thanks for the quick support ! Hookstate 4 basically covers every use case we came across in our project and its api is absolutely wonderful. Thanks for making such a great library for the community ❤️ 🙏🏻 Cheers ❇️ ✨

nateshmbhat avatar Sep 01 '22 13:09 nateshmbhat

Thanks. Please consider to help the project by spreading few words about it.

avkonst avatar Sep 04 '22 04:09 avkonst