How to pass a service to an effect
is there any way to pass bar to func here?
export class Foo extends Effect.Service<Foo>()("foo", {
effect: Effect.gen(function* () {
const bar = yield* Bar.Bar;
return {
baz: Effect.fn(function* () {
// Right now, `func` has `Bar.Bar` as a dependency, is it possible to pass `bar` to `func`
// instead?
return func();
}),
// more here...
};
}),
dependencies: [Bar.layer],
}) {}
const func = Effect.fn(function* () {
const bar = yield* Bar.Bar;
return bar.bar();
});export class Foo extends Effect.Service<Foo>()("foo", {
effect: Effect.gen(function* () {
const bar = yield* Bar.Bar;
return {
baz: Effect.fn(function* () {
// Right now, `func` has `Bar.Bar` as a dependency, is it possible to pass `bar` to `func`
// instead?
return func();
}),
// more here...
};
}),
dependencies: [Bar.layer],
}) {}
const func = Effect.fn(function* () {
const bar = yield* Bar.Bar;
return bar.bar();
});