0.1.0 #1
@@ -179,12 +179,12 @@ export const useFork: {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
export const useContextSync: {
|
export const useContext: {
|
||||||
<ROut, E, RIn>(
|
<ROut, E, RIn>(
|
||||||
layer: Layer.Layer<ROut, E, RIn>,
|
layer: Layer.Layer<ROut, E, RIn>,
|
||||||
options?: ScopeOptions,
|
options?: ScopeOptions,
|
||||||
): Effect.Effect<Context.Context<ROut>, E, Exclude<RIn, Scope.Scope>>
|
): Effect.Effect<Context.Context<ROut>, E, Exclude<RIn, Scope.Scope>>
|
||||||
} = Effect.fn("useContextSync")(function* <ROut, E, RIn>(
|
} = Effect.fn("useContext")(function* <ROut, E, RIn>(
|
||||||
layer: Layer.Layer<ROut, E, RIn>,
|
layer: Layer.Layer<ROut, E, RIn>,
|
||||||
options?: ScopeOptions,
|
options?: ScopeOptions,
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -10,8 +10,16 @@ const TodosStateLive = TodosState.Default("todos")
|
|||||||
|
|
||||||
export const Route = createFileRoute("/")({
|
export const Route = createFileRoute("/")({
|
||||||
component: Component.make(function* Index() {
|
component: Component.make(function* Index() {
|
||||||
const context = yield* Hook.useContextSync(TodosStateLive, { finalizerExecutionMode: "fork" })
|
const context = yield* Hook.useContext(TodosStateLive, { finalizerExecutionMode: "fork" })
|
||||||
return yield* Effect.provide(Component.use(Todos, Todos => <Todos />), context)
|
return yield* Effect.provide(Component.use(Todos, Todos => <Todos />), context)
|
||||||
|
|
||||||
|
// const context = yield* Hook.useContextAsync(TodosStateLive)
|
||||||
|
// return yield* AsyncData.match(context, {
|
||||||
|
// NoData: () => Effect.succeed(<Text>No data.</Text>),
|
||||||
|
// Loading: () => Effect.succeed(<Text>Loading...</Text>),
|
||||||
|
// Failure: () => Effect.succeed(<Text>Failed.</Text>),
|
||||||
|
// Success: context => Effect.provide(Component.use(Todos, Todos => <Todos />), context),
|
||||||
|
// })
|
||||||
}).pipe(
|
}).pipe(
|
||||||
Component.withRuntime(runtime.context)
|
Component.withRuntime(runtime.context)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user