Morglod/tsee

"once" subscriptions broke other "on" subscription

stels-cs opened this issue · 1 comments

In this example

import { EventEmitter } from './index';

const events = new EventEmitter<{
    foo: (a: number, b: string) => void,
}>();

events.once('foo', (a,b) => {
    console.log('ones listener foo', a,b)
})

events.on('foo', (a, b) => {
    console.log('default listener foo', a, b);
});

events.emit('foo', 1, 'first time');
events.emit('foo', 2, 'second time');

i expect to see logs like

ones listener foo 1 first time
default listener foo 1 first time
default listener foo 2 second time

but i see only

ones listener foo 1 first time
default listener foo 2 second time

I think problem in this line https://github.com/Morglod/tsee/blob/master/src/ee.ts#L17

because this.events modifides during call e in line https://github.com/Morglod/tsee/blob/master/src/ee.ts#L30

Thank you very much! Fixed in 1.3.3 version