diff --git a/packages/effect-fc/src/Suspense.ts b/packages/effect-fc/src/Async.ts similarity index 69% rename from packages/effect-fc/src/Suspense.ts rename to packages/effect-fc/src/Async.ts index bd9cb57..22fe2f1 100644 --- a/packages/effect-fc/src/Suspense.ts +++ b/packages/effect-fc/src/Async.ts @@ -3,14 +3,14 @@ import * as React from "react" import type * as Component from "./Component.js" -export const TypeId: unique symbol = Symbol.for("effect-fc/Suspense") +export const TypeId: unique symbol = Symbol.for("effect-fc/Async") export type TypeId = typeof TypeId -export interface Suspense extends Suspense.Options { +export interface Async extends Async.Options { readonly [TypeId]: TypeId } -export namespace Suspense { +export namespace Async { export interface Options { readonly defaultFallback?: React.ReactNode } @@ -23,13 +23,13 @@ const SuspenseProto = Object.freeze({ [TypeId]: TypeId, makeFunctionComponent

( - this: Component.Component & Suspense, + this: Component.Component & Async, runtimeRef: React.RefObject>>, scope: Scope.Scope, ) { const SuspenseInner = (props: { readonly promise: Promise }) => React.use(props.promise) - return ({ fallback, name, ...props }: Suspense.Props) => { + return ({ fallback, name, ...props }: Async.Props) => { const promise = Runtime.runPromise(runtimeRef.current)( Effect.provideService(this.body(props as P), Scope.Scope, scope) ) @@ -44,19 +44,19 @@ const SuspenseProto = Object.freeze({ } as const) -export const isSuspense = (u: unknown): u is Suspense => Predicate.hasProperty(u, TypeId) +export const isAsync = (u: unknown): u is Async => Predicate.hasProperty(u, TypeId) -export const suspense = >( +export const async = >( self: T ): ( & Omit> & Component.Component< - Component.Component.Props & Suspense.Props, + Component.Component.Props & Async.Props, Component.Component.Success, Component.Component.Error, Component.Component.Context > - & Suspense + & Async ) => Object.setPrototypeOf( Object.assign(function() {}, self), Object.freeze(Object.setPrototypeOf( @@ -66,16 +66,16 @@ export const suspense = >( ) export const withOptions: { - & Suspense>( - options: Partial + & Async>( + options: Partial ): (self: T) => T - & Suspense>( + & Async>( self: T, - options: Partial, + options: Partial, ): T -} = Function.dual(2, & Suspense>( +} = Function.dual(2, & Async>( self: T, - options: Partial, + options: Partial, ): T => Object.setPrototypeOf( Object.assign(function() {}, self, options), Object.getPrototypeOf(self), diff --git a/packages/effect-fc/src/index.ts b/packages/effect-fc/src/index.ts index 513ddd1..e3fe33f 100644 --- a/packages/effect-fc/src/index.ts +++ b/packages/effect-fc/src/index.ts @@ -1,5 +1,5 @@ +export * as Async from "./Async.js" export * as Component from "./Component.js" export * as Form from "./Form.js" export * as Memoized from "./Memoized.js" export * as ReactRuntime from "./ReactRuntime.js" -export * as Suspense from "./Suspense.js"