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

Function unwrapCommand

packages/effect-app/src/client/apiClientFactory.ts:234–256  ·  view source on GitHub ↗
(eff: Effect.Effect<any, any, any>)

Source from the content-addressed store, hash-verified

232 })
233
234 const unwrapCommand = (eff: Effect.Effect<any, any, any>): Effect.Effect<any, any, any> =>
235 eff.pipe(
236 Effect.flatMap((result: any) =>
237 Effect.gen(function*() {
238 const keys: ReadonlyArray<Invalidation.InvalidationKey> = result?.metadata?.invalidateQueries ?? []
239 const invalidationKeys = yield* InvalidationKeysFromServer
240 yield* Effect.forEach(keys, (key) => invalidationKeys.add(key), { discard: true })
241 yield* forwardDependencies(result?.metadata?.dataDependencies)
242 return result.payload
243 })
244 ),
245 Effect.catch((result: any) =>
246 result?._tag === "CommandFailureWithMetaData"
247 ? Effect.gen(function*() {
248 const keys: ReadonlyArray<Invalidation.InvalidationKey> = result.metadata?.invalidateQueries ?? []
249 const invalidationKeys = yield* InvalidationKeysFromServer
250 yield* Effect.forEach(keys, (key) => invalidationKeys.add(key), { discard: true })
251 yield* forwardDependencies(result.metadata?.dataDependencies)
252 return yield* Effect.fail(result.error)
253 })
254 : Effect.fail(result)
255 )
256 )
257
258 const unwrapQuery = (eff: Effect.Effect<any, any, any>): Effect.Effect<any, any, any> =>
259 eff.pipe(

Callers 1

buildEffectFunction · 0.85

Calls 6

forwardDependenciesFunction · 0.85
catchMethod · 0.80
pipeMethod · 0.65
forEachMethod · 0.65
addMethod · 0.65
failMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…