diff --git a/packages/effect-fc-next/src/Async.ts b/packages/effect-fc-next/src/Async.ts index 6495308..58b7f5a 100644 --- a/packages/effect-fc-next/src/Async.ts +++ b/packages/effect-fc-next/src/Async.ts @@ -1,5 +1,5 @@ /** biome-ignore-all lint/complexity/useArrowFunction: necessary for class prototypes */ -import { Context, Effect, type Equivalence, Function, Predicate, Scope } from "effect" +import { type Context, Effect, type Equivalence, Function, Predicate, Scope } from "effect" import * as React from "react" import * as Component from "./Component.js" @@ -45,7 +45,7 @@ export const AsyncPrototype: AsyncPrototype = Object.freeze({ return ({ fallback, name, ...props }: AsyncProps) => { const promise = Effect.runPromiseWith(contextRef.current)( - Effect.andThen( + Effect.flatMap( Component.useScope([], this), scope => Effect.provideService(this.body(props as P), Scope.Scope, scope), ) diff --git a/packages/effect-fc-next/src/Component.ts b/packages/effect-fc-next/src/Component.ts index aadc0a9..bec0610 100644 --- a/packages/effect-fc-next/src/Component.ts +++ b/packages/effect-fc-next/src/Component.ts @@ -59,7 +59,7 @@ export const ComponentImplPrototype: ComponentImplPrototype = Object.f contextRef: React.RefObject>>, ) { return (props: P) => Effect.runSyncWith(contextRef.current)( - Effect.andThen( + Effect.flatMap( useScope([], this), scope => Effect.provideService(this.body(props), Scope.Scope, scope), ) diff --git a/packages/effect-fc-next/src/ReactRuntime.ts b/packages/effect-fc-next/src/ReactRuntime.ts index 2c40a78..4413e3e 100644 --- a/packages/effect-fc-next/src/ReactRuntime.ts +++ b/packages/effect-fc-next/src/ReactRuntime.ts @@ -29,16 +29,16 @@ export const preludeLayer: Layer.Layer< ) -export const isReactRuntime = (u: unknown): u is ReactRuntime => Predicate.hasProperty(u, TypeId) +export const isReactRuntime = (u: unknown): u is ReactRuntime => Predicate.hasProperty(u, ReactRuntimeTypeId) export const make = ( layer: Layer.Layer, memoMap?: Layer.MemoMap, -): ReactRuntime | R, ER> => Object.setPrototypeOf( +): ReactRuntime | R, ER> => Object.setPrototypeOf( Object.assign(function() {}, { runtime: ManagedRuntime.make( Layer.merge(layer, preludeLayer), - memoMap, + { memoMap }, ), // biome-ignore lint/style/noNonNullAssertion: context initialization context: React.createContext>(null!),