0.2.0 (#18)
Lint / lint (push) Successful in 13s
Publish / publish (push) Successful in 19s

Co-authored-by: Renovate Bot <renovate-bot@valverde.cloud>
Co-authored-by: Julien Valverdé <julien.valverde@mailo.com>
Reviewed-on: Thilawyn/effect-fc#18
This commit was merged in pull request #18.
This commit is contained in:
2025-10-24 01:36:27 +02:00
parent 6bf4e33c29
commit a432993ac3
45 changed files with 701 additions and 994 deletions
+6 -4
View File
@@ -1,10 +1,10 @@
/** biome-ignore-all lint/complexity/useArrowFunction: necessary for class prototypes */
import { Effect, Function, Predicate, Runtime, Scope } from "effect"
import * as React from "react"
import type * as Component from "./Component.js"
import * as Component from "./Component.js"
export const TypeId: unique symbol = Symbol.for("effect-fc/Async")
export const TypeId: unique symbol = Symbol.for("@effect-fc/Async/Async")
export type TypeId = typeof TypeId
export interface Async extends Async.Options {
@@ -26,13 +26,15 @@ const SuspenseProto = Object.freeze({
makeFunctionComponent<P extends {}, A extends React.ReactNode, E, R>(
this: Component.Component<P, A, E, R> & Async,
runtimeRef: React.RefObject<Runtime.Runtime<Exclude<R, Scope.Scope>>>,
scope: Scope.Scope,
) {
const SuspenseInner = (props: { readonly promise: Promise<React.ReactNode> }) => React.use(props.promise)
return ({ fallback, name, ...props }: Async.Props) => {
const promise = Runtime.runPromise(runtimeRef.current)(
Effect.provideService(this.body(props as P), Scope.Scope, scope)
Effect.andThen(
Component.useScope([], this),
scope => Effect.provideService(this.body(props as P), Scope.Scope, scope),
)
)
return React.createElement(