@effect-rx/rx-react 0.24.2 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dts/index.d.ts +5 -5
- package/package.json +3 -3
- package/src/index.ts +12 -12
package/dist/dts/index.d.ts
CHANGED
@@ -54,7 +54,7 @@ export declare const useRxSet: <R, W>(rx: Rx.Writable<R, W>) => (_: W | ((_: R)
|
|
54
54
|
* @since 1.0.0
|
55
55
|
* @category hooks
|
56
56
|
*/
|
57
|
-
export declare const useRxSetPromise: <E, A, W>(rx: Rx.Writable<Result.Result<
|
57
|
+
export declare const useRxSetPromise: <E, A, W>(rx: Rx.Writable<Result.Result<A, E>, W>) => (_: W) => Promise<Exit.Exit<A, E>>;
|
58
58
|
/**
|
59
59
|
* @since 1.0.0
|
60
60
|
* @category hooks
|
@@ -69,16 +69,16 @@ export declare const useRx: <R, W>(rx: Rx.Writable<R, W>) => readonly [value: R,
|
|
69
69
|
* @since 1.0.0
|
70
70
|
* @category hooks
|
71
71
|
*/
|
72
|
-
export declare const useRxSuspense: <
|
72
|
+
export declare const useRxSuspense: <A, E>(rx: Rx.Rx<Result.Result<A, E>>, options?: {
|
73
73
|
readonly suspendOnWaiting?: boolean;
|
74
|
-
}) => Result.Success<
|
74
|
+
}) => Result.Success<A, E> | Result.Failure<A, E>;
|
75
75
|
/**
|
76
76
|
* @since 1.0.0
|
77
77
|
* @category hooks
|
78
78
|
*/
|
79
|
-
export declare const useRxSuspenseSuccess: <
|
79
|
+
export declare const useRxSuspenseSuccess: <A, E>(rx: Rx.Rx<Result.Result<A, E>>, options?: {
|
80
80
|
readonly suspendOnWaiting?: boolean;
|
81
|
-
}) => Result.Success<
|
81
|
+
}) => Result.Success<A, E>;
|
82
82
|
/**
|
83
83
|
* @since 1.0.0
|
84
84
|
* @category hooks
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@effect-rx/rx-react",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.25.0",
|
4
4
|
"description": "Reactive toolkit for Effect",
|
5
5
|
"license": "MIT",
|
6
6
|
"repository": {
|
@@ -10,10 +10,10 @@
|
|
10
10
|
"sideEffects": [],
|
11
11
|
"author": "Effect contributors",
|
12
12
|
"dependencies": {
|
13
|
-
"@effect-rx/rx": "^0.
|
13
|
+
"@effect-rx/rx": "^0.26.0"
|
14
14
|
},
|
15
15
|
"peerDependencies": {
|
16
|
-
"effect": "^2.
|
16
|
+
"effect": "^2.3.0",
|
17
17
|
"react": "^18"
|
18
18
|
},
|
19
19
|
"main": "./dist/cjs/index.js",
|
package/src/index.ts
CHANGED
@@ -103,8 +103,8 @@ function setRx<R, W>(registry: Registry.Registry, rx: Rx.Writable<R, W>): (_: W
|
|
103
103
|
|
104
104
|
function setRxPromise<E, A, W>(
|
105
105
|
registry: Registry.Registry,
|
106
|
-
rx: Rx.Writable<Result.Result<
|
107
|
-
): (_: W) => Promise<Exit.Exit<
|
106
|
+
rx: Rx.Writable<Result.Result<A, E>, W>
|
107
|
+
): (_: W) => Promise<Exit.Exit<A, E>> {
|
108
108
|
const cancelRef = React.useRef<Set<() => void>>(undefined as any)
|
109
109
|
if (!cancelRef.current) {
|
110
110
|
cancelRef.current = new Set()
|
@@ -159,8 +159,8 @@ export const useRxSet = <R, W>(rx: Rx.Writable<R, W>): (_: W | ((_: R) => W)) =>
|
|
159
159
|
* @category hooks
|
160
160
|
*/
|
161
161
|
export const useRxSetPromise = <E, A, W>(
|
162
|
-
rx: Rx.Writable<Result.Result<
|
163
|
-
): (_: W) => Promise<Exit.Exit<
|
162
|
+
rx: Rx.Writable<Result.Result<A, E>, W>
|
163
|
+
): (_: W) => Promise<Exit.Exit<A, E>> => {
|
164
164
|
const registry = React.useContext(RegistryContext)
|
165
165
|
return setRxPromise(registry, rx)
|
166
166
|
}
|
@@ -191,14 +191,14 @@ export const useRx = <R, W>(
|
|
191
191
|
] as const
|
192
192
|
}
|
193
193
|
|
194
|
-
type SuspenseResult<
|
194
|
+
type SuspenseResult<A, E> =
|
195
195
|
| {
|
196
196
|
readonly _tag: "Suspended"
|
197
197
|
readonly promise: Promise<void>
|
198
198
|
}
|
199
199
|
| {
|
200
200
|
readonly _tag: "Value"
|
201
|
-
readonly value: Result.Success<
|
201
|
+
readonly value: Result.Success<A, E> | Result.Failure<A, E>
|
202
202
|
}
|
203
203
|
|
204
204
|
const suspenseRx = Rx.family((rx: Rx.Rx<Result.Result<any, any>>) =>
|
@@ -233,10 +233,10 @@ const suspenseMounts = globalValue("@effect-rx/rx-react/suspenseMounts", () => n
|
|
233
233
|
* @since 1.0.0
|
234
234
|
* @category hooks
|
235
235
|
*/
|
236
|
-
export const useRxSuspense = <
|
237
|
-
rx: Rx.Rx<Result.Result<
|
236
|
+
export const useRxSuspense = <A, E>(
|
237
|
+
rx: Rx.Rx<Result.Result<A, E>>,
|
238
238
|
options?: { readonly suspendOnWaiting?: boolean }
|
239
|
-
): Result.Success<
|
239
|
+
): Result.Success<A, E> | Result.Failure<A, E> => {
|
240
240
|
const registry = React.useContext(RegistryContext)
|
241
241
|
const resultRx = React.useMemo(
|
242
242
|
() => (options?.suspendOnWaiting ? suspenseRxWaiting(rx) : suspenseRx(rx)),
|
@@ -264,10 +264,10 @@ export const useRxSuspense = <E, A>(
|
|
264
264
|
* @since 1.0.0
|
265
265
|
* @category hooks
|
266
266
|
*/
|
267
|
-
export const useRxSuspenseSuccess = <
|
268
|
-
rx: Rx.Rx<Result.Result<
|
267
|
+
export const useRxSuspenseSuccess = <A, E>(
|
268
|
+
rx: Rx.Rx<Result.Result<A, E>>,
|
269
269
|
options?: { readonly suspendOnWaiting?: boolean }
|
270
|
-
): Result.Success<
|
270
|
+
): Result.Success<A, E> => {
|
271
271
|
const result = useRxSuspense(rx, options)
|
272
272
|
if (result._tag === "Failure") {
|
273
273
|
throw Cause.squash(result.cause)
|