@@ -4,11 +4,11 @@ import * as Effect from "@effect/io/Effect"
4
4
import * as Layer from "@effect/io/Layer"
5
5
import type * as Runtime from "@effect/io/Runtime"
6
6
import * as Scope from "@effect/io/Scope"
7
- import { createContext } from "react"
8
7
import type { UseResult } from "effect-react/hooks/useResult"
9
8
import { makeUseResult } from "effect-react/hooks/useResult"
10
9
import type { UseResultCallback } from "effect-react/hooks/useResultCallback"
11
10
import { makeUseResultCallback } from "effect-react/hooks/useResultCallback"
11
+ import { createContext } from "react"
12
12
13
13
export { RuntimeContext } from "effect-react/internal/runtimeContext"
14
14
@@ -37,3 +37,25 @@ export const makeFromLayer = <R, E>(
37
37
useResult : makeUseResult ( RuntimeContext )
38
38
}
39
39
}
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