irc-framework icon indicating copy to clipboard operation
irc-framework copied to clipboard

channel.users is not updated before 'userlist' event is emitted

Open vith opened this issue 7 years ago • 1 comments

Using setTimeout with 0 delay can work around it.

vith avatar Apr 26 '18 17:04 vith

Just stepped through the event being emitted. The listener I added is being called before the internal one here: https://github.com/kiwiirc/irc-framework/blob/0551c957dff72860b6b721abbf06e6be4d7ed3ea/src/channel.js#L25

This happens because I register my event listener at startup, but the channel object is created much later.

For now I will just use the user list supplied in the event args instead of reading it from the channel property. But perhaps we can avoid this surprise by having a separate internal EventEmitter that is emitted to first so all the internal state can be correct before any listeners are called by the public emitter.

vith avatar May 31 '18 15:05 vith