class TestContext extends Context.Tag('TestContext')<
TestContext,
{a: string}
>() {
static Live = Layer.sync(TestContext, () => ({a: 'test'}))
}
const innerProgram = Effect.gen(function* (_) {
const test = yield* _(TestContext)
yield* _(Effect.log(test))
yield* _(Effect.log('I am running'))
})
// If I don't use and provide context the program 2 will run
.pipe(Effect.provide(TestContext.Live))
// Works if I provide the context this way
// .pipe(Effect.provideServiceEffect(TestContext, Effect.succeed({a: 'test'})))
const program = Effect.scoped(
Effect.gen(function* (_) {
const runFork = yield* _(FiberSet.makeRuntime<never>())
runFork(innerProgram)
// Works if sleep is added
// yield* _(Effect.sleep(2000))
// yield* _(Effect.log('I am done'))
})
)
Effect.runFork(program)
class TestContext extends Context.Tag('TestContext')<
TestContext,
{a: string}
>() {
static Live = Layer.sync(TestContext, () => ({a: 'test'}))
}
const innerProgram = Effect.gen(function* (_) {
const test = yield* _(TestContext)
yield* _(Effect.log(test))
yield* _(Effect.log('I am running'))
})
// If I don't use and provide context the program 2 will run
.pipe(Effect.provide(TestContext.Live))
// Works if I provide the context this way
// .pipe(Effect.provideServiceEffect(TestContext, Effect.succeed({a: 'test'})))
const program = Effect.scoped(
Effect.gen(function* (_) {
const runFork = yield* _(FiberSet.makeRuntime<never>())
runFork(innerProgram)
// Works if sleep is added
// yield* _(Effect.sleep(2000))
// yield* _(Effect.log('I am done'))
})
)
Effect.runFork(program)