Skip to content

Commit 7f402c1

Browse files
provide chain service reqs in multiChainFxFn
1 parent 29c50f6 commit 7f402c1

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/multi_chain.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,9 @@ export function multiChainServicesContext
213213
return rctx as Context.Context<ObjectChainsContextTagIdU<Chains> | Tag>
214214
}
215215

216-
// given a MultiChain return a FxFn to run any of its chains,
217-
// so can be used to invoke any of the chains
218-
// from any step which outputs a chain Input
216+
// given a MultiChain return a FxFn to run any of its chains ...
217+
// with all of the chain requirements provided - so only
218+
// the app service requirements are still to be provided
219219
export function multiChainFxFn
220220
<Tag extends MultiChainTag,
221221
const Chains extends ObjectChainList>
@@ -225,9 +225,13 @@ export function multiChainFxFn
225225
return <Input extends ObjectChainsInputU<Chains>>
226226
(i: Input) => {
227227

228-
return Effect.gen(function* (_) {
228+
const svcEff = Effect.gen(function* (_) {
229229
const svc = yield* _(multiChain.contextTag)
230230
return yield* _(svc.buildObject(i))
231231
})
232+
233+
const multiChainEff = Effect.provide(svcEff, multiChainServicesContext(multiChain))
234+
235+
return multiChainEff
232236
}
233237
}

src/multi_chain_test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ Deno.test("composition with multiChainServicesContext", () => {
280280
})
281281
})
282282

283-
Deno.test("composition with multiChainFxFn", () => {
283+
Deno.test("clean invocation with multiChainFxFn", () => {
284284
const mc = multiChain([
285285
getOrgProg,
286286
sendWelcomePushProg,
@@ -296,9 +296,7 @@ Deno.test("composition with multiChainFxFn", () => {
296296
}
297297

298298
const prog = fxFn(input)
299-
const almostRunnable = Effect.provide(prog, testServiceContext)
300-
const runnable = Effect.provide(almostRunnable,
301-
multiChainServicesContext(mc))
299+
const runnable = Effect.provide(prog, testServiceContext)
302300

303301
const r = Effect.runSync(runnable)
304302

0 commit comments

Comments
 (0)