[auth][js] Rename a few methods to make it easier to follow

This commit is contained in:
Chris Bianca 2017-10-27 11:55:00 +01:00
parent 807e581ec7
commit e535a1ebaa
1 changed files with 24 additions and 24 deletions

View File

@ -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}