@effect-app/vue 4.0.0-beta.178 → 4.0.0-beta.179
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/CHANGELOG.md +22 -0
- package/dist/makeClient.d.ts +5 -3
- package/dist/makeClient.d.ts.map +1 -1
- package/dist/makeClient.js +1 -1
- package/dist/mutate.d.ts +5 -2
- package/dist/mutate.d.ts.map +1 -1
- package/dist/mutate.js +11 -4
- package/package.json +2 -2
- package/src/makeClient.ts +10 -8
- package/src/mutate.ts +11 -5
- package/test/dist/streamFinal.test.d.ts.map +1 -0
- package/test/dist/stubs.d.ts +278 -45
- package/test/dist/stubs.d.ts.map +1 -1
- package/test/dist/stubs.js +31 -2
- package/test/makeClient.test.ts +24 -0
- package/test/streamFinal.test.ts +110 -0
- package/test/stubs.ts +30 -1
package/src/mutate.ts
CHANGED
|
@@ -419,6 +419,9 @@ export const useMakeMutation = () => {
|
|
|
419
419
|
* stream element. Queries are invalidated once when the stream finishes, regardless of
|
|
420
420
|
* success or failure.
|
|
421
421
|
*
|
|
422
|
+
* When the request declares a `final` schema, `execute` resolves with the last emitted value
|
|
423
|
+
* typed as `Final`; otherwise it resolves with `void`.
|
|
424
|
+
*
|
|
422
425
|
* Must be called inside a Vue setup context (uses `useQueryClient` internally).
|
|
423
426
|
*/
|
|
424
427
|
export const makeStreamMutation = () => {
|
|
@@ -434,7 +437,7 @@ export const makeStreamMutation = () => {
|
|
|
434
437
|
) => {
|
|
435
438
|
const state = shallowRef<AsyncResult.AsyncResult<any, any>>(AsyncResult.initial())
|
|
436
439
|
|
|
437
|
-
const runStream = (stream: Stream.Stream<any, any, any>, input?: unknown): Effect.Effect<
|
|
440
|
+
const runStream = (stream: Stream.Stream<any, any, any>, input?: unknown): Effect.Effect<any, never, any> => {
|
|
438
441
|
const invCache = buildInvalidateCache(queryClient, self, mergedInvalidation)
|
|
439
442
|
return Effect
|
|
440
443
|
.sync(() => {
|
|
@@ -463,13 +466,16 @@ export const makeStreamMutation = () => {
|
|
|
463
466
|
}
|
|
464
467
|
})
|
|
465
468
|
),
|
|
466
|
-
Effect.
|
|
469
|
+
Effect.flatMap((exit) => {
|
|
467
470
|
const current = state.value
|
|
468
471
|
const lastValue = AsyncResult.isSuccess(current) ? current.value : undefined
|
|
469
472
|
const invExit = exit._tag === "Success" ? Exit.succeed(lastValue) : exit
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
+
// Note: when the stream fails, `lastValue` is undefined. The failure is
|
|
474
|
+
// communicated via the reactive `state` ref (AsyncResult.failure). The
|
|
475
|
+
// execute effect always resolves successfully; callers should inspect the
|
|
476
|
+
// ref to distinguish success from failure.
|
|
477
|
+
return invCache(input, invExit, []).pipe(Effect.as(lastValue))
|
|
478
|
+
})
|
|
473
479
|
)
|
|
474
480
|
)
|
|
475
481
|
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamFinal.test.d.ts","sourceRoot":"","sources":["../streamFinal.test.ts"],"names":[],"mappings":""}
|