mirror of
https://github.com/meshcore-dev/meshcore.js.git
synced 2026-04-20 22:13:49 +00:00
show contacts list on connect
This commit is contained in:
parent
865ca127ac
commit
995e740347
5 changed files with 227 additions and 72 deletions
|
|
@ -26,6 +26,24 @@ class EventEmitter {
|
|||
|
||||
}
|
||||
|
||||
once(event, callback) {
|
||||
|
||||
// internal callback to handle the event
|
||||
const internalCallback = (...data) => {
|
||||
|
||||
// we received an event, so lets remove the event listener
|
||||
this.off(event, internalCallback);
|
||||
|
||||
// fire the original callback provided by the user
|
||||
setTimeout(() => callback(...data), 0);
|
||||
|
||||
};
|
||||
|
||||
// listen to this event
|
||||
this.on(event, internalCallback);
|
||||
|
||||
}
|
||||
|
||||
emit(event, ...data) {
|
||||
|
||||
// invoke each listener for this event
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue