Challenges with Using forkDaemon in Service Construction
I keep ending up in a situation where I want to construct a service that uses
In the example the layer is self-referential because of
In my app the use case is things like wrapping event listeners that have some relevance to a service. For example
Has anybody else run into this pattern where it would be nice for layer to be able to consume the service that it's producing? Any suggestions on a better way to structure this would be appreciated, thanks!
forkDaemon to start some long running work associated with the service but this results in a self-referential layer. For example:In the example the layer is self-referential because of
doBackgroundStuffWithTestService which obviously won't work. One solution could be to pass anything I need as function arguments to doBackgroundStuffWithTestService but that doesn't seem as clean as just consuming the service as things grow in complexity. In my app the use case is things like wrapping event listeners that have some relevance to a service. For example
DeviceStateService needs to forkDaemon a fiber to keep a subscription ref in sync with react-native's AppState.addEventListener.Has anybody else run into this pattern where it would be nice for layer to be able to consume the service that it's producing? Any suggestions on a better way to structure this would be appreciated, thanks!
