Newer version available
You’re viewing the API reference for version 3.0.3, but the latest version is 3.1.0. The latest version include may important updates and fixes.
View Latest Versionfunction createQueue
thefrontside/effectionfunction createQueue<T, TClose>(): Queue<T, TClose>
Creates a new queue. Queues are unlimited in size and sending a message to a queue is always synchronous.
Examples
Example 1
import { each, main, createQueue } from 'effection';
await main(function*() {
let queue = createQueue<number>();
queue.send(1);
queue.send(2);
queue.send(3);
let next = yield* queue.subscription.next();
while (!next.done) {
console.log("got number", next.value);
next = yield* queue.subscription.next();
}
});
Type Parameters
T the type of the items in the queue
TClose the type of the value that the queue is closed with
Return Type
Queue<T, TClose>