You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The use case is similar to using the already implemented store.subscribe(cb) method.
It's to trigger the callback immediately on subscribe.
I'm using it in vanillaJS. For instance to init my JS classes with values from the store.
Exemple :
exportdefaultclassMyExample{valueA=0;constructor(){subscribeKeys(webgl,['valueA'],this.handlePropsChanged);}handlePropsChanged=({ valueA })=>{if(valueA!=this.valueA){// Animate with the new values directly instantiation and all the other timesgsap.to(this,{ valueA, valueB,duration: 1});}}}
If it's a use case you don't want to support, maybe for consistency store.subscribe(cb) should be removed ?
We have both
store.subscribe(cb)
andstore.listen(cb)
to decide if we want to call the listeners immediately on subscribe or not.So why not having the same with
subscribeKeys(store, keys, cb)
alonglistenKeys(store, keys, cb)
?I'm using it in prod and it's working pretty good !
The text was updated successfully, but these errors were encountered: