0.1.2 #3

Merged
Thilawyn merged 28 commits from next into master 2025-07-23 21:28:25 +02:00
Showing only changes of commit f7534d63f8 - Show all commits

View File

@@ -380,29 +380,6 @@ export const suspense = <T extends Component<any, any, P>, P extends {}>(
)
export const withRuntime: {
<T extends Component<any, R, any>, R>(
context: React.Context<Runtime.Runtime<R>>,
): (self: T) => React.FC<T extends Suspense
? Component.Props<T> & SuspenseProps
: Component.Props<T>
>
<E, R, P extends {}>(
self: Component<E, R, P> & Suspense,
context: React.Context<Runtime.Runtime<R>>,
): React.FC<P & SuspenseProps>
<E, R, P extends {}>(
self: Component<E, R, P>,
context: React.Context<Runtime.Runtime<R>>,
): React.FC<P>
} = Function.dual(2, <E, R, P extends {}>(
self: Component<E, R, P>,
context: React.Context<Runtime.Runtime<R>>,
): React.FC<P> => function WithRuntime(props) {
const runtime = React.useContext(context)
return React.createElement(Runtime.runSync(runtime)(useFC(self)), props)
})
export const useFC: {
<E, R, P extends {}>(
self: Component<E, R, P> & Suspense
@@ -469,3 +446,26 @@ export const use: {
} = Effect.fn("use")(function*(self, fn) {
return fn(yield* useFC(self))
})
export const withRuntime: {
<T extends Component<any, R, any>, R>(
context: React.Context<Runtime.Runtime<R>>,
): (self: T) => React.FC<T extends Suspense
? Component.Props<T> & SuspenseProps
: Component.Props<T>
>
<E, R, P extends {}>(
self: Component<E, R, P> & Suspense,
context: React.Context<Runtime.Runtime<R>>,
): React.FC<P & SuspenseProps>
<E, R, P extends {}>(
self: Component<E, R, P>,
context: React.Context<Runtime.Runtime<R>>,
): React.FC<P>
} = Function.dual(2, <E, R, P extends {}>(
self: Component<E, R, P>,
context: React.Context<Runtime.Runtime<R>>,
): React.FC<P> => function WithRuntime(props) {
const runtime = React.useContext(context)
return React.createElement(Runtime.runSync(runtime)(useFC(self)), props)
})