Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Can't assign more than one handler to connection events #1933

Description

@melnikaite

I'd like to catch end event in one place and do reconnect and resubscribe to .allEvents in another place, but I can't assign more than function to connect end and error events of websocket provider. Here is part of code explaining why it happens

WebsocketProvider.prototype.on = function (type, callback) {

    if(typeof callback !== 'function')
        throw new Error('The second parameter callback must be a function.');

    switch(type){
        case 'data':
            this.notificationCallbacks.push(callback);
            break;

        case 'connect':
            this.connection.onopen = callback;
            break;

        case 'end':
            this.connection.onclose = callback;
            break;

        case 'error':
            this.connection.onerror = callback;
            break;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementIncludes improvements or optimizations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions