Skip to content

1.7.2

Compare
Choose a tag to compare
@vitaly-t vitaly-t released this 11 Mar 09:47
· 34 commits to master since this release
  • Extension function fromEmitterArgs has been refactored, to accept an optional tuple type, to make event arguments strongly-typed:
import {fromEmitterArgs} from 'sub-events/ext';

const e = new EventEmitter(); // our source/test emitter

type MyTuple = [number, string];

const onReceive = fromEmitterArgs<MyTuple>(e, 'receive'); // creating 'receive' event

onReceive.subscribe((data: MyTuple) => {
    // data is strongly-typed here:
    const s = data[0].toFixed(2); // 123.00
});

e.emit('receive', 123, 'hello'); // source emitter sends multiple arguments
  • Minor refactoring + documentation updates.