AbstractRouterManager

AbstractRouterManager ⇐ Class

Kind: global abstract class
Extends: Class
Mixes: MObjectStates
Manager:
Properties

NameTypeDescription
routesObject

[READ-ONLY] Routes defined so far

currentRouteNameString

The name of the route we are currently on

previousRouteNameString

The name of the route we were previously on

currentModuleIdString

This identifier of the module we are currently on

previousModuleIdString

This identifier of the module we were previously on

currentScreenScreen

The current displayed screen. Can only be null at startup, before the first screen has been shown. Once the first screen has been shown, it should never be null!

targetScreenScreen

The future screen as the screen that is in the process of being displayed. If null, it means that we are not in the process of displaying it.

allowConnectDataDuringAnimationBoolean

Flag (set by the application within its profile) to allow connect data during screen transition animations

moduleServiceModuleService

A reference on an instance of the Module service.

disableHistoryBoolean

Disable history recording (By default, it is set at false value)

AbstractRouterManager()

The router manager which manages screens’ registration with their lifecycle and their history.

displayScreen(screenId, [context]) ⇒ Promise.<Object, Error>

Display a screen: hides the current screen, shows the new one, fires all related events and sets focus on the new specified Screen.

Related widgets are automatically shown or hidden. Only widgets which are not shown in the current screen are shown (calls to widget.show()). Only widgets which are not hidden in the current screen are hidden (calls to widget.hide()).

The context is used as the first argument for all extension points; you can use it to pass additional options to your screens. The keys currentScreenId, targetScreenId and previousScreenId are automatically injected into the context and are reserved keywords.

Kind: instance method of AbstractRouterManager
Returns: Promise.<Object, Error> - A promise resolved with the context or rejected with the cause of the error

ParamTypeDescription
screenIdString

The identifier of the screen

[context]Object

The context shared between screens for the whole flow which contains additional options

[context.childToFocus]String

The view identifier or the child item to focus after the screen has been displayed

[context.skipHistory]boolean

If it is set to true then the screen to show, will not be pushed into the screen history when next screen will be displayed.

registerRoutes(routes, moduleId) ⇒ Promise.<Array.<String>>

Register the given routes.

Kind: instance method of AbstractRouterManager
Returns: Promise.<Array.<String>> - List of registered routes

ParamTypeDescription
routesTrait

The routes definition (warning: must be the Trait and not an instance!)

moduleIdString

The identifier of the module that handles the route

registerLazyRoutes(routes, moduleId) ⇒ Promise.<Array.<String>>

Register the given routes.

Kind: instance method of AbstractRouterManager
Returns: Promise.<Array.<String>> - List of registered routes

ParamTypeDescription
routesTrait

The routes definition (warning: must be the Trait and not an instance!)

moduleIdString

The identifier of the module that handles the route

getCurrentScreenAsync() ⇒ Promise.<Screen>

Method that is retrieving current used screen.

Kind: instance method of AbstractRouterManager
Returns: Promise.<Screen> - A reference on current used screen

route(routeName, [data]) ⇒ Promise.<Object, Error>

Go to a registered route.

Kind: instance method of AbstractRouterManager
Returns: Promise.<Object, Error> - Returns a promise resolved with the context, or rejected with the cause of the error

ParamTypeDescription
routeNameString

the route name

[data]Object

the route data (used by the route provider)

routeToPrevious(options) ⇒ Promise.<Object, Error>

Route to previous route.

Kind: instance method of AbstractRouterManager
Returns: Promise.<Object, Error> - Returns a promise resolved with the context, or rejected with the cause of the error

ParamTypeDescription
optionsObject

Optional parameters used as context which are shared between screens

reload(screen, options) ⇒ Promise.<Object, Error>

Reload the application with new parameters. For example, used to change the application’s language

Kind: instance method of AbstractRouterManager
Returns: Promise.<Object, Error> - Returns a promise resolved with the context, or rejected with the cause of the error

ParamTypeDescription
screenString | null

The reloaded screen (use 'null' value to keep the current screen)

optionsObject

The screen parameters

_displayScreen(targetScreen, context) ⇒ Promise.<Object, Error>

Manage the lifecycle of the screen

Kind: instance method of AbstractRouterManager
Returns: Promise.<Object, Error> - Returns a promise resolved with the context, or rejected with the cause of the error
Emits: RouterManager#event:screenChange
Access: protected

ParamTypeDescription
targetScreenAbstractScreen

The target screen (which will become the current screen)

contextObject

The context shared between screens for the whole flow (which contains additional options)

prepareData() ⇒ Promise

Call the prepareData method of the targetScreen In standard mode, returns the prepareDataPromise so it will block the flow until the promise has been resolved In deferred mode, it executes prepareData and gives the hand back immediately

Kind: inner method of _displayScreen

beforeShow() ⇒ Promise

Call the beforeShow method of the targetScreen

Kind: inner method of _displayScreen

beforeHide() ⇒ Promise

Call the beforeHide method of the currentScreen

Kind: inner method of _displayScreen

hideShow() ⇒ Promise

Call the hide method of the currentScreen (if any) Then call the show method of the targetScreen synchronously

Kind: inner method of _displayScreen

changeScreen() ⇒ Promise

Hide current screen, set target screen as new current screen and show it

Kind: inner method of _displayScreen

connectData() ⇒ Promise

Wait for prepareData to finish and connect data must be called when prepareData done but after show

Kind: inner method of _displayScreen

animate() ⇒ Promise

Wait for animations to finish

Kind: inner method of _displayScreen

ready() ⇒ Promise

Wait for prepareDataPromise and go to state ready

Kind: inner method of _displayScreen

_catchScreenDataError(targetScreen, err) ⇒ Promise.<Object, Error>

Handles the error that can happen during the process of displaying a screen

Kind: instance method of AbstractRouterManager
Returns: Promise.<Object, Error> - Returns a promise resolved with the context, or rejected with the cause of the error
Access: protected

ParamTypeDescription
targetScreenAbstractScreen

A reference on the targeted screen

errError

The cause of the error

_catchScreenError(targetScreen, currentScreen, context, err)

Handles the error that can happen during the process of displaying a screen

Kind: instance method of AbstractRouterManager
Access: protected

ParamTypeDescription
targetScreenAbstractScreen

A reference on the targeted screen

currentScreenAbstractScreen | null

A reference on current screen

contextObject

The context shared between screens for the whole flow (which contains additional options)

errError

The cause of the error

_changeCurrentScreen(targetScreen, context)

Change the current screen reference

Kind: instance method of AbstractRouterManager
Access: protected

ParamTypeDescription
targetScreenAbstractScreen

The target screen, which will become the current screen

contextObject

The context shared between screens for the whole flow (which contains additional options)

_onRouteChange(routeName, data) ⇒ Promise.<Object, Error>

Event handler called when going to a new route.

Kind: instance method of AbstractRouterManager
Returns: Promise.<Object, Error> - Returns a promise resolved with the context, or rejected with the cause of the error
Access: protected

ParamTypeDescription
routeNameString

The name of the route

dataObject

The data of the route

_changePreviousModuleId(moduleId)

Change the previous module identifier (if and only if the moduleId we are entering in, is different) Useful in order to know from which ‘corner’ we are coming from.

Kind: instance method of AbstractRouterManager
Access: protected

ParamTypeDescription
moduleIdString

The identifier of the module we are enterring in.

_reload(screen, [options]) ⇒ Promise.<Object, Error>

Abstract method to be implemented in order to reload current application.

Kind: instance abstract method of AbstractRouterManager
Returns: Promise.<Object, Error> - Returns a promise resolved with the context, or rejected with the cause of the error
Access: protected

ParamType
screenAbstractScreen
[options]Object

__notImplementedPromise(methodName) ⇒ Promise.<*, Error>

Return a promise rejected with a “You must implement xxx method” error and that will fire the onError event.

Kind: instance method of AbstractRouterManager
Returns: Promise.<*, Error> - A rejected promise
Access: protected

ParamTypeDescription
methodNameString

The name of the method that is not implemented

“routeChange”

Fired event when the manager is going to a given route

Kind: event emitted by AbstractRouterManager

STATE_INIT : number

State where the Screen instance is created

Kind: static constant of AbstractRouterManager
Default: 0

STATE_BEFORE_SHOW : number

State where the target screen is about to be shown

Kind: static constant of AbstractRouterManager
Default: 1

STATE_PREPARE_DATA : number

State where the data for the target screen are prepared/fetched

Kind: static constant of AbstractRouterManager
Default: 2

STATE_BEFORE_HIDE : number

State where the current screen is about to be hidden

Kind: static constant of AbstractRouterManager
Default: 3

STATE_HIDE : number

State where the current screen is hidden.

Kind: static constant of AbstractRouterManager
Default: 4

STATE_SHOW : number

State where the target screen (which is now the current screen) is shown

Kind: static constant of AbstractRouterManager
Default: 5

STATE_READY : number

State where the screen is ready It’s data have been fetched, the viewed are fed and rendered

Kind: static constant of AbstractRouterManager
Default: 6

STATE_ERROR : number

State where there was an error when displaying a screen

Kind: static constant of AbstractRouterManager
Default: 7

STATES : Array.<string>

Application states

Kind: static constant of AbstractRouterManager