const parentEffect = Effect.gen(function* () {
// Get a runner with the same dependencies as the parent effect
const { runEffectSync, runEffectAsync } = yield* Effect.tools;
const someNonEffectType = new SomeNonEffectType({
// onMessage expects a promise
onMessage: (message) =>
runEffectAsync(
Effect.gen(function* () {
/// do something with the message in an effect context that has the same dependencies as the parent effect
})
),
});
/// do something with the non-effect type
});
const parentEffect = Effect.gen(function* () {
// Get a runner with the same dependencies as the parent effect
const { runEffectSync, runEffectAsync } = yield* Effect.tools;
const someNonEffectType = new SomeNonEffectType({
// onMessage expects a promise
onMessage: (message) =>
runEffectAsync(
Effect.gen(function* () {
/// do something with the message in an effect context that has the same dependencies as the parent effect
})
),
});
/// do something with the non-effect type
});