@@ -4,11 +4,11 @@ import * as Effect from "@effect/io/Effect"
44import * as Layer from "@effect/io/Layer"
55import type * as Runtime from "@effect/io/Runtime"
66import * as Scope from "@effect/io/Scope"
7- import { createContext } from "react"
87import type { UseResult } from "effect-react/hooks/useResult"
98import { makeUseResult } from "effect-react/hooks/useResult"
109import type { UseResultCallback } from "effect-react/hooks/useResultCallback"
1110import { makeUseResultCallback } from "effect-react/hooks/useResultCallback"
11+ import { createContext } from "react"
1212
1313export { RuntimeContext } from "effect-react/internal/runtimeContext"
1414
@@ -37,3 +37,25 @@ export const makeFromLayer = <R, E>(
3737 useResult : makeUseResult ( RuntimeContext )
3838 }
3939}
40+
41+ export const makeFromRuntime = < R > (
42+ runtime : Runtime . Runtime < R >
43+ ) : ReactEffectBag < R > => {
44+ const RuntimeContext = createContext ( runtime )
45+
46+ return {
47+ RuntimeContext,
48+ useResultCallback : makeUseResultCallback ( RuntimeContext ) ,
49+ useResult : makeUseResult ( RuntimeContext )
50+ }
51+ }
52+
53+ export const makeFromRuntimeContext = < R > (
54+ RuntimeContext : React . Context < Runtime . Runtime < R > >
55+ ) : ReactEffectBag < R > => {
56+ return {
57+ RuntimeContext,
58+ useResultCallback : makeUseResultCallback ( RuntimeContext ) ,
59+ useResult : makeUseResult ( RuntimeContext )
60+ }
61+ }
0 commit comments