@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/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<void, never, any> => {
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.tap((exit) => {
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
- return invCache(input, invExit, [])
471
- }),
472
- Effect.asVoid
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":""}