Fix
All checks were successful
Lint / lint (push) Successful in 11s

This commit is contained in:
Julien Valverdé
2026-03-03 13:47:48 +01:00
parent 3794f56a86
commit 1f47887643
2 changed files with 11 additions and 9 deletions

View File

@@ -12,8 +12,6 @@ export interface AsyncPrototype {
readonly [AsyncTypeId]: AsyncTypeId readonly [AsyncTypeId]: AsyncTypeId
} }
const PromiseTypeId: unique symbol = Symbol.for("@effect-fc/Async/Promise")
export const AsyncPrototype: AsyncPrototype = Object.freeze({ export const AsyncPrototype: AsyncPrototype = Object.freeze({
[AsyncTypeId]: AsyncTypeId, [AsyncTypeId]: AsyncTypeId,
@@ -21,7 +19,7 @@ export const AsyncPrototype: AsyncPrototype = Object.freeze({
this: Component.Component<P, A, E, R> & Async, this: Component.Component<P, A, E, R> & Async,
runtimeRef: React.RefObject<Runtime.Runtime<Exclude<R, Scope.Scope>>>, runtimeRef: React.RefObject<Runtime.Runtime<Exclude<R, Scope.Scope>>>,
) { ) {
const Inner = (props: { readonly [PromiseTypeId]: Promise<React.ReactNode> }) => React.use(props[PromiseTypeId]) const Inner = (props: { readonly promise: Promise<React.ReactNode> }) => React.use(props.promise)
Inner.displayName = `${ this.displayName }Inner` Inner.displayName = `${ this.displayName }Inner`
return (props: P) => { return (props: P) => {
@@ -32,7 +30,7 @@ export const AsyncPrototype: AsyncPrototype = Object.freeze({
) )
) )
return React.createElement(Inner, { ...props, [PromiseTypeId]: promise }) return React.createElement(Inner, { promise })
} }
}, },
} as const) } as const)

View File

@@ -26,10 +26,12 @@ class AsyncFetchPostView extends Component.make("AsyncFetchPostView")(function*(
Effect.andThen(Schema.decodeUnknown(Post)), Effect.andThen(Schema.decodeUnknown(Post)),
), [props.id]) ), [props.id])
return <div> return (
<Heading>{post.title}</Heading> <div>
<Text>{post.body}</Text> <Heading>{post.title}</Heading>
</div> <Text>{post.body}</Text>
</div>
)
}).pipe( }).pipe(
Async.async, Async.async,
Memoized.memoized, Memoized.memoized,
@@ -48,7 +50,9 @@ const AsyncRouteComponent = Component.make("AsyncRouteView")(function*() {
onValueChange={flow(Array.head, Option.getOrThrow, setId)} onValueChange={flow(Array.head, Option.getOrThrow, setId)}
/> />
<AsyncFetchPost id={id} /> <React.Suspense fallback={<Text>Loading...</Text>}>
<AsyncFetchPost id={id} />
</React.Suspense>
</Flex> </Flex>
</Container> </Container>
) )