0.1.0 #1

Merged
Thilawyn merged 81 commits from next into master 2025-07-17 21:17:57 +02:00
2 changed files with 11 additions and 3 deletions
Showing only changes of commit 802297626c - Show all commits

View File

@@ -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,
) { ) {

View File

@@ -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)
) )