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 9 additions and 2 deletions
Showing only changes of commit 40eb25d2c3 - Show all commits

View File

@@ -110,6 +110,8 @@ export interface Suspense {
readonly suspense: true readonly suspense: true
} }
export type SuspenseProps = Omit<React.SuspenseProps, "children">
export const suspense = <T extends Component<any, any, any>>( export const suspense = <T extends Component<any, any, any>>(
self: ExcludeKeys<T, keyof Suspense> self: ExcludeKeys<T, keyof Suspense>
): T & Suspense => Object.setPrototypeOf( ): T & Suspense => Object.setPrototypeOf(
@@ -119,6 +121,9 @@ export const suspense = <T extends Component<any, any, any>>(
export const useFC: { export const useFC: {
<E, R, P extends {}>(
self: Component<E, R, ExcludeKeys<P, keyof SuspenseProps>> & Suspense
): Effect.Effect<React.FC<P & SuspenseProps>, never, Exclude<R, Scope.Scope>>
<E, R, P extends {}>( <E, R, P extends {}>(
self: Component<E, R, P> self: Component<E, R, P>
): Effect.Effect<React.FC<P>, never, Exclude<R, Scope.Scope>> ): Effect.Effect<React.FC<P>, never, Exclude<R, Scope.Scope>>

View File

@@ -8,7 +8,7 @@ import * as React from "react"
const RouteComponent = Component.make(function* AsyncRendering() { const RouteComponent = Component.make(function* AsyncRendering() {
const VAsyncComponent = yield* Component.useSuspenseFC(AsyncComponent) const VAsyncComponent = yield* Component.useFC(AsyncComponent)
const [input, setInput] = React.useState("") const [input, setInput] = React.useState("")
return <> return <>
@@ -34,7 +34,9 @@ const AsyncComponent = Component.make(function* AsyncComponent() {
<Text>Rendered!</Text><br /> <Text>Rendered!</Text><br />
<VSubComponent /> <VSubComponent />
</> </>
}) }).pipe(
Component.suspense
)
const SubComponent = Component.make(function* SubComponent() { const SubComponent = Component.make(function* SubComponent() {
const [state] = React.useState(yield* Hook.useOnce(() => Effect.provide(makeUuid4, GetRandomValues.CryptoRandom))) const [state] = React.useState(yield* Hook.useOnce(() => Effect.provide(makeUuid4, GetRandomValues.CryptoRandom)))