diff --git a/packages/auth/lib/PhoneAuthListener.js b/packages/auth/lib/PhoneAuthListener.js index 46a5bcb2f6..171da0cc53 100644 --- a/packages/auth/lib/PhoneAuthListener.js +++ b/packages/auth/lib/PhoneAuthListener.js @@ -68,7 +68,10 @@ export default class PhoneAuthListener { for (let i = 0, len = events.length; i < len; i++) { const type = events[i]; - this._auth.emitter.once(this._internalEvents[type], this[`_${type}Handler`].bind(this)); + const subscription = this._auth.emitter.addListener(this._internalEvents[type], event => { + this[`_${type}Handler`](event); + subscription.remove(); + }); } } @@ -203,11 +206,17 @@ export default class PhoneAuthListener { this._addUserObserver(observer); if (isFunction(errorCb)) { - this._auth.emitter.once(this._publicEvents.error, errorCb); + const subscription = this._auth.emitter.addListener(this._publicEvents.error, () => { + errorCb; + subscription.remove(); + }); } if (isFunction(successCb)) { - this._auth.emitter.once(this._publicEvents.success, successCb); + const subscription = this._auth.emitter.addListener(this._publicEvents.success, () => { + successCb; + subscription.remove(); + }); } return this; diff --git a/packages/database/lib/DatabaseSyncTree.js b/packages/database/lib/DatabaseSyncTree.js index dc3440263a..25f4e522db 100644 --- a/packages/database/lib/DatabaseSyncTree.js +++ b/packages/database/lib/DatabaseSyncTree.js @@ -262,10 +262,10 @@ class DatabaseSyncTree { this._reverseLookup[eventRegistrationKey] = registration; if (once) { - SharedEventEmitter.once( - eventRegistrationKey, - this._onOnceRemoveRegistration(eventRegistrationKey, listener), - ); + const subscription = SharedEventEmitter.addListener(eventRegistrationKey, event => { + this._onOnceRemoveRegistration(eventRegistrationKey, listener, event); + subscription.remove(); + }); } else { SharedEventEmitter.addListener(eventRegistrationKey, listener); }