From e535a1ebaa43d0de4ea73e56227c307ba1fbcff1 Mon Sep 17 00:00:00 2001 From: Chris Bianca Date: Fri, 27 Oct 2017 11:55:00 +0100 Subject: [PATCH] [auth][js] Rename a few methods to make it easier to follow --- lib/modules/auth/index.js | 48 +++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/modules/auth/index.js b/lib/modules/auth/index.js index 2b222bae..3146e74e 100644 --- a/lib/modules/auth/index.js +++ b/lib/modules/auth/index.js @@ -32,21 +32,21 @@ export default class Auth extends ModuleBase { // sub to internal native event - this fans out to // public event name: onAuthStateChanged this._getAppEventName('auth_state_changed'), - this._onAuthStateChanged.bind(this), + this._onInternalAuthStateChanged.bind(this), ); this.addListener( // sub to internal native event - this fans out to // public events based on event.type this._getAppEventName('phone_auth_state_changed'), - this._onPhoneAuthStateChanged.bind(this), + this._onInternalPhoneAuthStateChanged.bind(this), ); this.addListener( // sub to internal native event - this fans out to // public event name: onIdTokenChanged this._getAppEventName('auth_id_token_changed'), - this._onIdTokenChanged.bind(this), + this._onInternalIdTokenChanged.bind(this), ); this._native.addAuthStateListener(); @@ -58,7 +58,7 @@ export default class Auth extends ModuleBase { * @param event * @private */ - _onPhoneAuthStateChanged(event: Object) { + _onInternalPhoneAuthStateChanged(event: Object) { const eventKey = `phone:auth:${event.requestKey}:${event.type}`; this.emit(eventKey, event.state); } @@ -73,40 +73,22 @@ export default class Auth extends ModuleBase { * @param auth * @private */ - _onAuthStateChanged(auth: AuthResultType) { + _onInternalAuthStateChanged(auth: AuthResultType) { this._setAuthState(auth); this.emit(this._getAppEventName('onAuthStateChanged'), this._user); } - /** - * Remove auth change listener - * @param listener - */ - _offAuthStateChanged(listener: Function) { - this.log.info('Removing onAuthStateChanged listener'); - this.removeListener(this._getAppEventName('onAuthStateChanged'), listener); - } - /** * Internal auth changed listener * @param auth * @param emit * @private */ - _onIdTokenChanged(auth: AuthResultType) { + _onInternalIdTokenChanged(auth: AuthResultType) { this._setAuthState(auth); this.emit(this._getAppEventName('onIdTokenChanged'), this._user); } - /** - * Remove id token change listener - * @param listener - */ - _offIdTokenChanged(listener: Function) { - this.log.info('Removing onIdTokenChanged listener'); - this.removeListener(this._getAppEventName('onIdTokenChanged'), listener); - } - /** * Intercept all user actions and send their results to * auth state change before resolving @@ -138,6 +120,15 @@ export default class Auth extends ModuleBase { return this._offAuthStateChanged.bind(this, listener); } + /** + * Remove auth change listener + * @param listener + */ + _offAuthStateChanged(listener: Function) { + this.log.info('Removing onAuthStateChanged listener'); + this.removeListener(this._getAppEventName('onAuthStateChanged'), listener); + } + /** * Listen for id token changes. * @param listener @@ -149,6 +140,15 @@ export default class Auth extends ModuleBase { return this._offIdTokenChanged.bind(this, listener); } + /** + * Remove id token change listener + * @param listener + */ + _offIdTokenChanged(listener: Function) { + this.log.info('Removing onIdTokenChanged listener'); + this.removeListener(this._getAppEventName('onIdTokenChanged'), listener); + } + /** * Sign the current user out * @return {Promise}