salt-sdk - v0.0.45
    Preparing search index...

    Class InvitationListenerSealed

    Listens for organisation invitations issued to the authenticated user, a client learns of one as it happens instead of always polling with Salt.getOrganisationsInvitations.

    Obtain one via Salt.listenToOrganisationInvitations.

    const invitations = await salt.listenToOrganisationInvitations();

    invitations.on('invitationReceived', async (invitation) => {
    console.log(`Invited to ${invitation.organisation.name}`);
    await salt.acceptOrganisationInvitation(invitation.id);
    });

    // later
    invitations.stop();

    Hierarchy

    Index
    prefixed: string | boolean
    • Remove all listeners, or those of the specified event.

      Parameters

      • Optionalevent: keyof InvitationListenerEvents

      Returns this

    • Subscribes to invitation events on the underlying socket. Called by Salt.listenToOrganisationInvitations after construction; you only need to call it again after a matching stop to resume listening. Idempotent — calling while already started is a no-op.

      Returns void

      invitations.start();
      
    • Stop listening for invitations. Unsubscribes without closing the underlying websocket — call Salt.disconnect to close the socket and allow the Node.js process to exit.

      Returns void

      invitations.stop();
      salt.disconnect();