const messageQueue = yield* Queue.unbounded<string>()
yield* Stream.fromQueue(messageQueue).pipe(
Stream.runForEach(() => Effect.gen(function*() {
yield* Effect.sleep("10 seconds")
yield* Effect.log("Done sleeping", message)
})),
Effect.forkScoped,
)
yield* messageQueue.offer("hello")
yield* messageQueue.offer("world") // this would cancel the first one, so only "Done sleeping", world would get printed
const messageQueue = yield* Queue.unbounded<string>()
yield* Stream.fromQueue(messageQueue).pipe(
Stream.runForEach(() => Effect.gen(function*() {
yield* Effect.sleep("10 seconds")
yield* Effect.log("Done sleeping", message)
})),
Effect.forkScoped,
)
yield* messageQueue.offer("hello")
yield* messageQueue.offer("world") // this would cancel the first one, so only "Done sleeping", world would get printed