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
More details and problems with this solution here: #666
I suggest to add new api to cover all cases with external observables - with full Fork API support
functionfromReactiveSource<Payload,S>(config: {source?: Store<S>,setupOn: Clock<any>,// it is essential for Fork API support to have explicit unit to setup subscription in correct scopesetup: (scopedTrigger: (p: Payload)=>Payload,sourceData?: S)=>void;}): Event<Payload>
with usage like this:
const$history=createStore(createBrowserHistory())consthistoryUpdated=fromReactiveSource<HistoryUpdate>({source: $history,setupOn: [appStarted, ...],setup: (scopedTrigger,history)=>{history.listen(scopedTrigger)}})// or with targetfromReactiveSource<HistoryUpdate>({source: $history,setupOn: [appStarted, ...],setup: (scopedTrigger,history)=>{history.listen(scopedTrigger)},target: [historyUpdated, ...]})
I think, it will allow to cover all cases with external subscriptions + scope support, since the latter requires explicit trigger to setup subscription, so its correctly scope bounded
Also, i think, it might be useful to have an option to provide destruction function and trigger:
This will allow to avoid memory leaks during SSR usage, where user would need to create separate subscription for every scope (i.e. per request) and also destroy this subscription, when request is handled and scope should be thrown away
There is a common pattern to connect external event source to effector with scope support:
More details and problems with this solution here: #666
I suggest to add new api to cover all cases with external observables - with full Fork API support
with usage like this:
I think, it will allow to cover all cases with external subscriptions + scope support, since the latter requires explicit trigger to setup subscription, so its correctly scope bounded
Also, i think, it might be useful to have an option to provide destruction function and trigger:
This will allow to avoid memory leaks during SSR usage, where user would need to create separate subscription for every scope (i.e. per request) and also destroy this subscription, when request is handled and scope should be thrown away
Originally posted by @AlexandrHoroshih in #490 (comment)
The text was updated successfully, but these errors were encountered: