Skip to content

Commit

Permalink
feat(eventemitter): add unsubscribe function
Browse files Browse the repository at this point in the history
  • Loading branch information
wewoor committed Dec 2, 2020
1 parent 9f527f5 commit 697c431
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/common/event/eventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@ export class EventEmitter {
}
}

// TODO
public unsubscribe() {}
public unsubscribe(name: string | string[]) {
if (Array.isArray(name)) {
name.forEach((key: string) => {
this._events.delete(key);
});
} else {
this._events.delete(name);
}
}

public assignEvent<T>(name: string, callback: Function) {
const event = this._events.get(name);
Expand Down

0 comments on commit 697c431

Please sign in to comment.