@v4fire/client
Version:
V4Fire client core library
25 lines (18 loc) • 631 B
Markdown
# core/component/queue-emitter
This module provides a class to organize event emitter with support of ordering events.
```js
import QueueEmitter from 'core/component/queue-emitter';
const
eventEmitter = new QueueEmitter();
// These listeners is invoked only when all specified events was emitted
eventEmitter.on(new Set(['foo', 'bar']), () => {
console.log('Crash!');
});
// This listener does not have any events to listen, and it will be invoked after calling the .drain method
eventEmitter.on(undefined, () => {
console.log('Boom!');
});
eventEmitter.drain();
eventEmitter.emit('foo');
eventEmitter.emit('bar');
```