Skip to content

Conversation

@perrin4869
Copy link
Contributor

I've been running this patch locally for a while.
It is technically a breaking change, because .on would stop attaching events directly to the internal client...
But I think this is an important change, because otherwise we don't have any way to be notified of when a client is initiated.
I think another problem with the old approach is that, if the _client gets refreshed at any point during the runtime, for example, by calling end, the events attached to it would disappear.

The way this issue is solved with this PR would be:

        client.on("init", (client) => {
            client.on("error", logger.error.bind(logger));
            client.on("notice", logger.info.bind(logger, "notice: "));
            client.on("notification", logger.info.bind(logger, "notification: "));
            client.on("end", logger.info.bind(logger, "end: "));
            client.on("drain", logger.info.bind(logger, "drain: "));
        });

With this method, if end and connect are called, the events will be reattached to the new client

@perrin4869 perrin4869 force-pushed the feat/event-emitter branch from 84e793d to b27e440 Compare May 13, 2025 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant