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
Would be nice to get an example with shared/concurrent access to resources.
Im coming from rxjs, where one can create a shared observable source which refcounts (e.g. wrapped event emitter).
// this will subscribe to an eventemitter, then share a subject which refcounts // it will setup and tear down the eventemitter subscription depending on how many subscriptions are openconstsharedSource=fromEvent(eventEmitter,'changes').pipe(share())// this will setup event emitter subscriptionconstsub1=sharedSource.subscribe(e=>{})// this will join the subscription and consume the same eventsconstsub2=sharedSource.subscribe(e=>{});// this will NOT clean up emitter subscription, as sub2 is still runningsub1.unsubscribe()// this will tear down emitter subscription as nobody is subscribed anymoresub2.unsubscribe()
So I'd like to consume a resource in multiple places at the same time especially with a longer-lived data types like a queue or a stream. I'm thinking of an injectable Effect service layer that provides a Stream (from Effect) or a Queue of events. I've watched this video https://www.youtube.com/watch?v=8B6YAax5Tes but it's outdated. If I were to have a file watcher service which different parts of the applogic subscribe to the file changes that would be a good example.
I guess it could be done manually by returning multiple copies of a stream or maybe I would need to rewire my brain first to not think of the solution in rxjs ways.
The text was updated successfully, but these errors were encountered:
Would be nice to get an example with shared/concurrent access to resources.
Im coming from rxjs, where one can create a shared observable source which refcounts (e.g. wrapped event emitter).
So I'd like to consume a resource in multiple places at the same time especially with a longer-lived data types like a queue or a stream. I'm thinking of an injectable Effect service layer that provides a Stream (from Effect) or a Queue of events. I've watched this video https://www.youtube.com/watch?v=8B6YAax5Tes but it's outdated. If I were to have a file watcher service which different parts of the applogic subscribe to the file changes that would be a good example.
I guess it could be done manually by returning multiple copies of a stream or maybe I would need to rewire my brain first to not think of the solution in rxjs ways.
The text was updated successfully, but these errors were encountered: