| 10 | |
| 11 | // @effect-diagnostics-next-line missingEffectServiceDependency:off |
| 12 | class MyContextProvider extends Context.Service<MyContextProvider>()( |
| 13 | "MyContextProvider", |
| 14 | { |
| 15 | make: Effect.gen(function*() { |
| 16 | yield* SomeService |
| 17 | if (Math.random() > 0.5) return yield* new CustomError1() |
| 18 | |
| 19 | return Effect.gen(function*() { |
| 20 | // the only requirements you can have are the one provided by HttpLayerRouter.Provided |
| 21 | yield* Scope.Scope |
| 22 | |
| 23 | yield* Effect.logInfo("MyContextProviderGen", "this is a generator") |
| 24 | yield* Effect.succeed("this is a generator") |
| 25 | |
| 26 | return Some.context({ a: 1 }) |
| 27 | }) |
| 28 | }) |
| 29 | } |
| 30 | ) { |
| 31 | static readonly Default = Layer.effect(this, this.make) |
| 32 | } |
| 33 | |
| 34 | class MyContextProvider2 extends Context.Service<MyContextProvider2>()( |
| 35 | "MyContextProvider2", |