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

Function effect

packages/infra/test/rpc-e2e-invalidation.test.ts:180–210  ·  view source on GitHub ↗
(match)

Source from the content-addressed store, hash-verified

178const router = Router(InvRsc)({
179 dependencies: [RepoItems.Default, OtherItems.Default],
180 *effect(match) {
181 const repo = yield* RepoItems
182 const otherRepo = yield* OtherItems
183 return match({
184 DoNothing: () => Effect.void,
185 DoWithDynamicKey: Effect.fnUntraced(function*() {
186 yield* Invalidation.InvalidationSet.use((_) => _.add(DynamicKey))
187 return "done"
188 }),
189 DoWithBothKeys: Effect.fnUntraced(function*() {
190 yield* Invalidation.InvalidationSet.use((_) => _.add(DynamicKey))
191 yield* Invalidation.InvalidationSet.use((_) => _.add(ExtraKey))
192 return 99
193 }),
194 DoAndFail: Effect.fnUntraced(function*() {
195 yield* Invalidation.InvalidationSet.use((_) => _.add(DynamicKey))
196 return yield* Effect.fail(new CmdBoom({ reason: "intentional failure" }))
197 }),
198 StreamWithKey: () =>
199 Stream.fromIterable([1, 2, 3]).pipe(
200 Stream.tap(() => Invalidation.InvalidationSet.use((_) => _.add(StreamKey)))
201 ),
202 StreamWithRepoWrite: () =>
203 Stream.fromIterable([1, 2, 3]).pipe(
204 Stream.tap((n) => repo.save(new RepoItem({ id: String(n), label: "x" })).pipe(Effect.orDie))
205 ),
206 GetRepoCount: () => repo.all.pipe(Effect.map((_) => _.length), Effect.orDie),
207 SaveRepoItem: ({ id, label }) => repo.save(new RepoItem({ id, label })).pipe(Effect.orDie),
208 SaveOtherItem: ({ id, label }) => otherRepo.save(new OtherItem({ id, label })).pipe(Effect.orDie)
209 })
210 }
211})
212
213const RpcRouterLayer = matchAll({ router })

Callers

nothing calls this directly

Calls 7

useMethod · 0.65
addMethod · 0.65
pipeMethod · 0.65
mapMethod · 0.65
matchFunction · 0.50
StringInterface · 0.50
failMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…