@@ -636,15 +636,6 @@ export declare namespace provide {
|
||||
* Component.provide(TodosService.Default),
|
||||
* )
|
||||
* ```
|
||||
*
|
||||
* @example Providing a layer with dependencies
|
||||
* ```tsx
|
||||
* const UserViewLive = Component.provide(
|
||||
* UserView,
|
||||
* UserService.layer,
|
||||
* )
|
||||
* // UserViewLive still requires UserRepository, which UserService.layer needs.
|
||||
* ```
|
||||
*/
|
||||
export const provide: {
|
||||
<ROut, E, RIn>(
|
||||
@@ -659,10 +650,10 @@ export const provide: {
|
||||
layer: Layer.Layer<ROut, E, RIn>,
|
||||
): provide.Result<T, ROut, E, RIn> => Object.setPrototypeOf(
|
||||
Object.assign(function() {}, self, {
|
||||
body: Effect.fnUntraced(function*(props: Component.Props<T>) {
|
||||
const context = yield* useLayer(layer)
|
||||
return React.createElement(yield* Effect.provide(self.use, context), props)
|
||||
}),
|
||||
body: (props: Component.Props<T>) => Effect.flatMap(
|
||||
useLayer(layer),
|
||||
context => Effect.provide(self.body(props), context),
|
||||
),
|
||||
}),
|
||||
Object.getPrototypeOf(self),
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user