import { Effect, Console, Schedule } from "effect"
const barJob = Effect.repeat(
Console.log("Still running!"),
Schedule.fixed("1 second")
)
const program = Effect.scoped(
Effect.gen(function* () {
const scope = yield* Effect.scope
yield* Effect.scoped(
Effect.gen(function* () {
yield* Effect.forkIn(barJob, scope)
yield* Effect.sleep("3 seconds")
console.log("The innermost scope is about to be closed.")
})
)
yield* Effect.sleep("5 seconds")
console.log("The outer scope is about to be closed.")
})
)
Effect.runPromise(program)
import { Effect, Console, Schedule } from "effect"
const barJob = Effect.repeat(
Console.log("Still running!"),
Schedule.fixed("1 second")
)
const program = Effect.scoped(
Effect.gen(function* () {
const scope = yield* Effect.scope
yield* Effect.scoped(
Effect.gen(function* () {
yield* Effect.forkIn(barJob, scope)
yield* Effect.sleep("3 seconds")
console.log("The innermost scope is about to be closed.")
})
)
yield* Effect.sleep("5 seconds")
console.log("The outer scope is about to be closed.")
})
)
Effect.runPromise(program)