0.1.2 #3
@@ -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)
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user