Skip to content

Commit

Permalink
feat: Implement Eventemitter#removeAllListener. (#1762)
Browse files Browse the repository at this point in the history
* feat: Implement Eventemitter#removeAllListener.

Make it possible to remove all listeners for the sign client. Currently it is only possible to remove one listener at a time by passing the event it listens on and the callback function.

* lint: modify to conform prettier requirements

Co-authored-by: Gancho Radkov <[email protected]>
  • Loading branch information
antondalgren and ganchoradkov authored Dec 20, 2022
1 parent 0cdf2a2 commit 2d80e19
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/sign-client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ export class SignClient extends ISignClient {
return this.events.removeListener(name, listener);
};

public removeAllListeners: ISignClientEvents["removeAllListeners"] = (name) => {
return this.events.removeAllListeners(name);
};

// ---------- Engine ----------------------------------------------- //

public connect: ISignClient["connect"] = async (params) => {
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/sign-client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export abstract class ISignClientEvents extends EventEmmiter {
event: E,
listener: (args: SignClientTypes.EventArguments[E]) => any,
) => this;

public abstract removeAllListeners: <E extends SignClientTypes.Event>(event: E) => this;
}

export abstract class ISignClient {
Expand Down

0 comments on commit 2d80e19

Please sign in to comment.