import { Console, Duration, Effect, Schedule } from 'effect'
const failingJob = Effect.gen(function* (_) {
yield* _(Effect.sleep(Duration.seconds(3)))
console.log('what a nice sleep!')
yield* _(Effect.fail('oh no'))
})
const otherJob = Effect.repeat(
Console.log('job still running!'),
Schedule.fixed('1 seconds'),
)
const program = Effect.gen(function* (_) {
yield* _(Effect.fork(failingJob))
yield* _(Effect.fork(otherJob))
yield* _(Effect.sleep(Duration.infinity))
})
Effect.runPromise(program)
// prints:
// job still running!
// job still running!
// job still running!
// what a nice sleep!
// job still running!
// job still running!
import { Console, Duration, Effect, Schedule } from 'effect'
const failingJob = Effect.gen(function* (_) {
yield* _(Effect.sleep(Duration.seconds(3)))
console.log('what a nice sleep!')
yield* _(Effect.fail('oh no'))
})
const otherJob = Effect.repeat(
Console.log('job still running!'),
Schedule.fixed('1 seconds'),
)
const program = Effect.gen(function* (_) {
yield* _(Effect.fork(failingJob))
yield* _(Effect.fork(otherJob))
yield* _(Effect.sleep(Duration.infinity))
})
Effect.runPromise(program)
// prints:
// job still running!
// job still running!
// job still running!
// what a nice sleep!
// job still running!
// job still running!