Infinite async generator. Iterates messages pushed to it until closed. Only one consumer is expected to use a Machina instance at a time.
Example 1
Example 1
// Create the Machina instance const machina = new Machina<string>(); // Async generator loop async function getMessages() { for await (const msg of machina.stream()) { console.log(msg); } } // Start the generator getMessages(); // Push messages to it machina.push('hello!'); machina.push('whats up?'); machina.push('greetings');
new
Machina(signal?: AbortSignal)
Get messages as an AsyncIterable.
private
abort(): void
Stops streaming and throws an error to the consumer.