Change useContextFromLayer to useLayer
Lint / lint (push) Failing after 43s

This commit is contained in:
Julien Valverdé
2026-07-20 20:40:13 +02:00
parent 19d5aba009
commit 9a93d72e48
13 changed files with 25 additions and 34 deletions
+5 -7
View File
@@ -1099,7 +1099,7 @@ export declare namespace useContext {
* ```tsx
* const MyLayer = Layer.succeed(MyService, new MyServiceImpl())
* const MyComponent = Component.make(function*() {
* const context = yield* Component.useContextFromLayer(MyLayer)
* const context = yield* Component.useLayer(MyLayer)
* const Sub = yield* SubComponent.use.pipe(
* Effect.provide(context)
* )
@@ -1111,7 +1111,7 @@ export declare namespace useContext {
* @example With memoized layer
* ```tsx
* const MyComponent = Component.make(function*(props: { id: string })) {
* const context = yield* Component.useContextFromLayer(
* const context = yield* Component.useLayer(
* React.useMemo(() => Layer.succeed(MyService, new MyServiceImpl(props.id)), [props.id])
* )
* const Sub = yield* SubComponent.use.pipe(
@@ -1126,17 +1126,15 @@ export declare namespace useContext {
* ```tsx
* const MyAsyncLayer = Layer.effect(MyService, someAsyncEffect)
* const MyComponent = Component.make(function*() {
* const context = yield* Component.useContextFromLayer(MyAsyncLayer)
* const Sub = yield* SubComponent.use.pipe(
* Effect.provide(context)
* )
* const context = yield* Component.useLayer(MyAsyncLayer)
* const Sub = yield* Effect.provide(SubComponent, context)
*
* return <Sub />
* }).pipe(
* Async.async // Required to handle async layer effects
* )
*/
export const useContextFromLayer = <ROut, E, RIn>(
export const useLayer = <ROut, E, RIn>(
layer: Layer.Layer<ROut, E, RIn>,
options?: useContext.Options,
): Effect.Effect<Context.Context<ROut>, E, RIn | Scope.Scope> => useOnChange(() => Effect.flatMap(