MCPcopy Create free account
hub / github.com/effect-app/libs / MyContextProvider3

Class MyContextProvider3

packages/infra/test/controller.test.ts:51–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51class MyContextProvider3 extends RpcX.RpcMiddleware.Tag<MyContextProvider3, {
52 provides: Some
53 requires: SomeElse
54}>()("MyContextProvider3") {
55 static Default = Layer.make(this, {
56 dependencies: [SomeService.Default],
57 *make() {
58 yield* SomeService
59 if (Math.random() > 0.5) return yield* new CustomError1()
60
61 return Effect.fnUntraced(function*(effect) {
62 yield* SomeElse
63 // the only requirements you can have are the one provided by HttpLayerRouter.Provided
64 yield* Scope.Scope
65
66 yield* Effect.logInfo("MyContextProviderGen", "this is a generator")
67 yield* Effect.succeed("this is a generator")
68
69 // this is allowed here but mergeContextProviders/MergedContextProvider will trigger an error
70 // yield* SomeElse
71
72 // currently the effectful context provider cannot trigger an error when building the per request context
73 // this is allowed here but mergeContextProviders/MergedContextProvider will trigger an error
74 // if (Math.random() > 0.5) return yield* new CustomError2()
75
76 return yield* Effect.provideService(effect, Some, Some.of({ a: 1 }))
77 })
78 }
79 })
80}
81
82expectTypeOf(MyContextProvider3.Default).toEqualTypeOf<
83 Layer.Layer<MyContextProvider3, CustomError1, never> & {

Callers

nothing calls this directly

Calls 1

makeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…