Reference Source
public class | source

AuthLoadingPresenter

Extends:

BasePresenter → AuthLoadingPresenter

Class for the auth loading presenter to check if the authentication state is valid. Uses the persist storage as the model.

Constructor Summary

Public Constructor
public

Creates an instance of AuthLoadingPresenter.

Member Summary

Public Members
public

Unsubscribe from models

public

onUpdated(data: Object): *

Called when a response is received from the Home and the Alert models after it has received data.

public

tryLogout(shouldLogout: Boolean, onSuccess: Function, onFailure: Function): *

Try to logout.

Private Members
private
private
private
private

Method Summary

Public Methods
public

async checkAuthState(onSuccess: Function, onFailure: Function)

Asynchronously check the authentication state of the user to see if they are logged in.

public

onRetrievalSuccess(userToken: string, onSuccess: Function, onFailure: Function)

Check if the userToken is valid and if it is, then call the onSuccess callback, otherwise call the onFailure callback.

public

setCallback(callback: Function)

Sets the callback to be called when data is received.

Inherited Summary

From class BasePresenter
public

getData: *

Gets the data from the model.

public

onUpdated(newData: Object): *

This method is called when the model's data has changed and the observers are being notified.

public

update(newData: Object): *

Sends an update to the model with new data.

Public Constructors

public constructor() source

Creates an instance of AuthLoadingPresenter. Subscribes to models to await data

Public Members

public onDestroy: * source

Unsubscribe from models

public onUpdated(data: Object): * source

Called when a response is received from the Home and the Alert models after it has received data. Acquires a lock to make sure that both don't enter at the same time.

Override:

BasePresenter#onUpdated

public tryLogout(shouldLogout: Boolean, onSuccess: Function, onFailure: Function): * source

Try to logout. Function is called on every entry to the authloading view so only execute logout if logout is requested.

Private Members

private _callback: * source

private _dataCount: number source

private _dataLoaded: boolean source

private _numModels: * source

Public Methods

public async checkAuthState(onSuccess: Function, onFailure: Function) source

Asynchronously check the authentication state of the user to see if they are logged in.

Params:

NameTypeAttributeDescription
onSuccess Function

A success callback

onFailure Function

A failure callback

public onRetrievalSuccess(userToken: string, onSuccess: Function, onFailure: Function) source

Check if the userToken is valid and if it is, then call the onSuccess callback, otherwise call the onFailure callback.

Params:

NameTypeAttributeDescription
userToken string

A user token

onSuccess Function

A success callback

onFailure Function

A failure callback

public setCallback(callback: Function) source

Sets the callback to be called when data is received.

Params:

NameTypeAttributeDescription
callback Function

A function to call when data is received