Skip to content

1.8.2

Compare
Choose a tag to compare
@vitaly-t vitaly-t released this 13 Mar 08:25
· 23 commits to master since this release

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);
    }
})();