( init: (ctx: InstanceContext) => Effect.Effect<A, E, R | Scope.Scope>, )
| 24 | export const directory = Effect.map(context, (ctx) => ctx.directory) |
| 25 | |
| 26 | export const make = <A, E = never, R = never>( |
| 27 | init: (ctx: InstanceContext) => Effect.Effect<A, E, R | Scope.Scope>, |
| 28 | ): Effect.Effect<InstanceState<A, E, Exclude<R, Scope.Scope>>, never, R | Scope.Scope> => |
| 29 | Effect.gen(function* () { |
| 30 | const cache = yield* ScopedCache.make<string, A, E, R>({ |
| 31 | capacity: Number.POSITIVE_INFINITY, |
| 32 | lookup: () => |
| 33 | Effect.gen(function* () { |
| 34 | return yield* init(yield* context) |
| 35 | }), |
| 36 | }) |
| 37 | |
| 38 | const off = registerDisposer((directory) => Effect.runPromise(ScopedCache.invalidate(cache, directory))) |
| 39 | yield* Effect.addFinalizer(() => Effect.sync(off)) |
| 40 | |
| 41 | return { |
| 42 | [TypeId]: TypeId, |
| 43 | cache, |
| 44 | } |
| 45 | }) |
| 46 | |
| 47 | export const get = <A, E, R>(self: InstanceState<A, E, R>) => |
| 48 | Effect.gen(function* () { |
nothing calls this directly
no test coverage detected