Skip to content

Commit

Permalink
feat: add logs for on & off listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardssh committed Dec 22, 2021
1 parent 9853eb8 commit 2715dee
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,8 @@ export function on(name: string, cb: ProcedureListener) {
throw new Error(`on expects 2 arguments: "name" and "cb" ("${name}")`);
}

log(`Registered procedure listener "${name}"`);

const listeners = glob.__rpcEvListeners[name] || new Set();
listeners.add(cb);

Expand All @@ -680,6 +682,7 @@ export function off(name: string, cb: ProcedureListener) {
const listeners = glob.__rpcEvListeners[name];

if (listeners) {
log(`Unregistered procedure listener "${name}"`);
listeners.delete(cb);
}
}
Expand Down

0 comments on commit 2715dee

Please sign in to comment.