Effect CommunityEC
Effect Communityβ€’2mo agoβ€’
10 replies
spaceemotion

How to Provide Scope to a Service Created with `Layer.scoped()`

I think I'm not quite getting how to merge and provide the layers. It seems that when I use Effect.Service, the scoping of the service happens in the background, but how do I provide the proper scope to a service I created via Layer.scoped()?
declare const browserNetworkServiceLayer: Layer.Layer<NetworkService, never, never>;
declare const ioLayer: Layer.Layer<EntityIO, never, never>;

declare const syncQueueLayer: Layer.Layer<SyncQueue, never, NetworkService>;
declare const syncManagerLayer: Layer.Layer<SyncManagerService, never, EntityIO | SyncQueue | Scope>;

const queueLayer = syncQueueLayer.pipe(browserNetworkServiceLayer);
const syncLayer = syncManagerLayer.pipe(
  Layer.provide(ioLayer),
  Layer.provide(queueLayer),
  // How do I fix that syncManager requires a scope?
);

ManagedRuntime.make(syncLayer);
Was this page helpful?