AbstractRouterManager
On this page
- AbstractRouterManager ⇐
Class
- AbstractRouterManager()
- displayScreen(screenId, [context]) ⇒
Promise.<Object, Error>
- registerRoutes(routes, moduleId) ⇒
Promise.<Array.<String>>
- registerLazyRoutes(routes, moduleId) ⇒
Promise.<Array.<String>>
- getCurrentScreenAsync() ⇒
Promise.<Screen>
- route(routeName, [data]) ⇒
Promise.<Object, Error>
- routeToPrevious(options) ⇒
Promise.<Object, Error>
- reload(screen, options) ⇒
Promise.<Object, Error>
- _displayScreen(targetScreen, context) ⇒
Promise.<Object, Error>
- _catchScreenDataError(targetScreen, err) ⇒
Promise.<Object, Error>
- _catchScreenError(targetScreen, currentScreen, context, err)
- _changeCurrentScreen(targetScreen, context)
- _onRouteChange(routeName, data) ⇒
Promise.<Object, Error>
- _changePreviousModuleId(moduleId)
- _reload(screen, [options]) ⇒
Promise.<Object, Error>
- __notImplementedPromise(methodName) ⇒
Promise.<*, Error>
- “routeChange”
- STATE_INIT :
number
- STATE_BEFORE_SHOW :
number
- STATE_PREPARE_DATA :
number
- STATE_BEFORE_HIDE :
number
- STATE_HIDE :
number
- STATE_SHOW :
number
- STATE_READY :
number
- STATE_ERROR :
number
- STATES :
Array.<string>
AbstractRouterManager ⇐ Class
Kind: global abstract class
Extends: Class
Mixes: MObjectStates
Manager:
Properties
Name | Type | Description |
---|---|---|
routes | Object | [READ-ONLY] Routes defined so far |
currentRouteName | String | The name of the route we are currently on |
previousRouteName | String | The name of the route we were previously on |
currentModuleId | String | This identifier of the module we are currently on |
previousModuleId | String | This identifier of the module we were previously on |
currentScreen | Screen | 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! |
targetScreen | Screen | 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. |
allowConnectDataDuringAnimation | Boolean | Flag (set by the application within its profile) to allow connect data during screen transition animations |
moduleService | ModuleService | A reference on an instance of the Module service. |
disableHistory | Boolean | Disable history recording (By default, it is set at false value) |
- AbstractRouterManager ⇐
Class
- new AbstractRouterManager()
- instance
- .displayScreen(screenId, [context]) ⇒
Promise.<Object, Error>
- .registerRoutes(routes, moduleId) ⇒
Promise.<Array.<String>>
- .registerLazyRoutes(routes, moduleId) ⇒
Promise.<Array.<String>>
- .getCurrentScreenAsync() ⇒
Promise.<Screen>
- .route(routeName, [data]) ⇒
Promise.<Object, Error>
- .routeToPrevious(options) ⇒
Promise.<Object, Error>
- .reload(screen, options) ⇒
Promise.<Object, Error>
- ._displayScreen(targetScreen, context) ⇒
Promise.<Object, Error>
- ~prepareData() ⇒
Promise
- ~beforeShow() ⇒
Promise
- ~beforeHide() ⇒
Promise
- ~hideShow() ⇒
Promise
- ~changeScreen() ⇒
Promise
- ~connectData() ⇒
Promise
- ~animate() ⇒
Promise
- ~ready() ⇒
Promise
- ~prepareData() ⇒
- ._catchScreenDataError(targetScreen, err) ⇒
Promise.<Object, Error>
- ._catchScreenError(targetScreen, currentScreen, context, err)
- ._changeCurrentScreen(targetScreen, context)
- ._onRouteChange(routeName, data) ⇒
Promise.<Object, Error>
- ._changePreviousModuleId(moduleId)
- ._reload(screen, [options]) ⇒
Promise.<Object, Error>
- .__notImplementedPromise(methodName) ⇒
Promise.<*, Error>
- “routeChange”
- .displayScreen(screenId, [context]) ⇒
- static
- .STATE_INIT :
number
- .STATE_BEFORE_SHOW :
number
- .STATE_PREPARE_DATA :
number
- .STATE_BEFORE_HIDE :
number
- .STATE_HIDE :
number
- .STATE_SHOW :
number
- .STATE_READY :
number
- .STATE_ERROR :
number
- .STATES :
Array.<string>
- .STATE_INIT :
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
Param | Type | Description |
---|---|---|
screenId | String | 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 |
registerRoutes(routes, moduleId) ⇒ Promise.<Array.<String>>
Register the given routes.
Kind: instance method of AbstractRouterManager
Returns: Promise.<Array.<String>>
- List of registered routes
Param | Type | Description |
---|---|---|
routes | Trait | The routes definition (warning: must be the Trait and not an instance!) |
moduleId | String | 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
Param | Type | Description |
---|---|---|
routes | Trait | The routes definition (warning: must be the Trait and not an instance!) |
moduleId | String | 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
Param | Type | Description |
---|---|---|
routeName | String | 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
Param | Type | Description |
---|---|---|
options | Object | 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
Param | Type | Description |
---|---|---|
screen | String | null | The reloaded screen (use 'null' value to keep the current screen) |
options | Object | 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
Param | Type | Description |
---|---|---|
targetScreen | AbstractScreen | The target screen (which will become the current screen) |
context | Object | The context shared between screens for the whole flow (which contains additional options) |
- ._displayScreen(targetScreen, context) ⇒
Promise.<Object, Error>
- ~prepareData() ⇒
Promise
- ~beforeShow() ⇒
Promise
- ~beforeHide() ⇒
Promise
- ~hideShow() ⇒
Promise
- ~changeScreen() ⇒
Promise
- ~connectData() ⇒
Promise
- ~animate() ⇒
Promise
- ~ready() ⇒
Promise
- ~prepareData() ⇒
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
Param | Type | Description |
---|---|---|
targetScreen | AbstractScreen | A reference on the targeted screen |
err | Error | 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
Param | Type | Description |
---|---|---|
targetScreen | AbstractScreen | A reference on the targeted screen |
currentScreen | AbstractScreen | null | A reference on current screen |
context | Object | The context shared between screens for the whole flow (which contains additional options) |
err | Error | The cause of the error |
_changeCurrentScreen(targetScreen, context)
Change the current screen reference
Kind: instance method of AbstractRouterManager
Access: protected
Param | Type | Description |
---|---|---|
targetScreen | AbstractScreen | The target screen, which will become the current screen |
context | Object | 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
Param | Type | Description |
---|---|---|
routeName | String | The name of the route |
data | Object | 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
Param | Type | Description |
---|---|---|
moduleId | String | 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
Param | Type |
---|---|
screen | AbstractScreen |
[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
Param | Type | Description |
---|---|---|
methodName | String | 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