Work
All checks were successful
Lint / lint (push) Successful in 10s

This commit is contained in:
Julien Valverdé
2025-07-21 01:50:00 +02:00
parent 5f34ea8df5
commit f7534d63f8

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: { export const useFC: {
<E, R, P extends {}>( <E, R, P extends {}>(
self: Component<E, R, P> & Suspense self: Component<E, R, P> & Suspense
@@ -469,3 +446,26 @@ export const use: {
} = Effect.fn("use")(function*(self, fn) { } = Effect.fn("use")(function*(self, fn) {
return fn(yield* useFC(self)) 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)
})