1.8.2
Refactoring method emit:
- It now returns the event object itself, rather than the number of possible recipients. Now you can chain emit operations:
event.emit(1).emit(2).emit(3)
- EmitSchedule has been updated, to allow initial delay before enumerating subscriptions.
Below is the complete test app, showing that when using EmitSchedule set to next
or async
,
we are getting enough initial delay to subscribe to the event, and still get the value:
import {EmitSchedule, SubEvent} from 'sub-events';
const event = new SubEvent<number>();
event.emit(123, {schedule: EmitSchedule.next});
(async function () {
try {
// under Nodejs, works even with timeout = 0 or without timeout at all ;)
const data = await event.toPromise({timeout: 1});
console.log(data); // outputs 123
} catch (e) {
console.log(e);
}
})();