MCPcopy Create free account
hub / github.com/effect-app/libs / makeInvocationEffect

Function makeInvocationEffect

packages/vue/src/mutate.ts:453–479  ·  view source on GitHub ↗
(input: unknown, source: Stream.Stream<any, any, any>)

Source from the content-addressed store, hash-verified

451 const r = (i: I, options?: MutationOptionsBase) =>
452 invalidateQueries(self, options, queryInvalidator)(self.handler(i), i)
453 return Object.assign(r, { id: self.id }) as any
454 }
455 return useMutation
456}
457
458/**
459 * Returns a stream-based mutation factory for use with `streamFn`.
460 * The outer Effect sets up per-invocation invalidation scaffolding
461 * and returns a stream that triggers query invalidation via `Stream.ensuring` when it completes.
462 *
463 * Use with `streamFn` / `Command.streamFn(id)(mutateHandler, ...combinators)` so that
464 * the command manages its own reactive state internally.
465 */
466export const makeStreamMutation2 = <RInvalidator>(queryInvalidator: QueryInvalidator<RInvalidator>) => {
467 return (
468 self: {
469 id: string
470 options?: ClientForOptions
471 disableQueryInvalidation?: boolean
472 handler: (i: any) => Stream.Stream<any, any, any>
473 },
474 mergedInvalidation?: MutationOptionsBase["queryInvalidation"]
475 ) => {
476 const invCache = buildInvalidateCache(self, mergedInvalidation, queryInvalidator)
477
478 const makeInvocationEffect = (input: unknown, source: Stream.Stream<any, any, any>) =>
479 Effect.gen(function*() {
480 const keysRef = yield* Ref.make<ReadonlyArray<InvalidationKey>>([])
481 // Server invalidation keys stay settlement-only: flushing them from `add` refetched
482 // live queries once per chunk (One-Pick List storms). Write-deps flush once when the

Callers 1

makeStreamMutation2Function · 0.85

Calls 6

makeMethod · 0.65
pipeMethod · 0.65
setMethod · 0.65
getMethod · 0.65
succeedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…