Class: ClientPageManager
@ima/core.ClientPageManager
Page manager for controller on the client side.
Hierarchy
↳
ClientPageManager
Constructors
constructor
• new ClientPageManager(pageFactory
, pageRenderer
, pageStateManager
, handlerRegistry
, dispatcher
, window
, eventBus
)
Initializes the client-side page manager.
Parameters
Name | Type | Description |
---|---|---|
pageFactory | PageFactory | Factory used by the page manager to create instances of the controller for the current route, and decorate the controllers and page state managers. |
pageRenderer | PageRenderer | The current renderer of the page. |
pageStateManager | PageStateManager <{}> | - |
handlerRegistry | PageHandlerRegistry | Instance of HandlerRegistry that holds a list of pre-manage and post-manage handlers. |
dispatcher | Dispatcher | IMA Dispatcher. |
window | Window | The utility for manipulating the global context and global client-side-specific APIs. |
eventBus | EventBus | The event bus for dispatching and listening for custom IMA events propagated through the DOM. |
Overrides
AbstractPageManager.constructor
Defined in
packages/core/src/page/manager/ClientPageManager.ts:70
Properties
_dispatcher
• Protected
_dispatcher: Dispatcher
Inherited from
AbstractPageManager._dispatcher
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:81
_eventBus
• Private
_eventBus: EventBus
The event bus for dispatching and listening for custom IMA events propagated through the DOM.
Defined in
packages/core/src/page/manager/ClientPageManager.ts:33
_managedPage
• Protected
_managedPage: ManagedPage
Details of the currently managed page.
Inherited from
AbstractPageManager._managedPage
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:68
_pageFactory
• Protected
_pageFactory: PageFactory
Factory used by the page manager to create instances of the controller for the current route, and decorate the controllers and page state managers.
Inherited from
AbstractPageManager._pageFactory
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:63
_pageHandlerRegistry
• Protected
_pageHandlerRegistry: PageHandlerRegistry
A registry that holds a list of pre-manage and post-manage handlers.
Inherited from
AbstractPageManager._pageHandlerRegistry
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:80
_pageRenderer
• Protected
_pageRenderer: PageRenderer
The current renderer of the page.
Inherited from
AbstractPageManager._pageRenderer
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:72
_pageStateManager
• Protected
_pageStateManager: PageStateManager
<{}>
The current page state manager.
Inherited from
AbstractPageManager._pageStateManager
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:76
_previousManagedPage
• Protected
_previousManagedPage: ManagedPage
Snapshot of the previously managed page before it was replaced with a new one
Inherited from
AbstractPageManager._previousManagedPage
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:57
_window
• Private
_window: Window
The utility for manipulating the global context and global client-side-specific APIs.
Defined in
packages/core/src/page/manager/ClientPageManager.ts:28
Accessors
$dependencies
• Static
get
$dependencies(): Dependencies
Returns
Defined in
packages/core/src/page/manager/ClientPageManager.ts:42
Methods
#cancelable
▸ Private
#cancelable<T
>(promise
): Promise
<T
>
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
promise | T |
Returns
Promise
<T
>
Inherited from
AbstractPageManager.#cancelable
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:849
_activateController
▸ Protected
_activateController(): Promise
<void
>
Activate managed instance of controller.
Returns
Promise
<void
>
Inherited from
AbstractPageManager._activateController
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:553
_activateExtensions
▸ Protected
_activateExtensions(): Promise
<void
>
Activate extensions for managed instance of controller.
Returns
Promise
<void
>
Inherited from
AbstractPageManager._activateExtensions
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:567
_activatePageSource
▸ Protected
_activatePageSource(): Promise
<void
>
Activate page source so call activate method on controller and his extensions.
Returns
Promise
<void
>
Inherited from
AbstractPageManager._activatePageSource
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:533
_boundOnCustomEventHandler
▸ Private
_boundOnCustomEventHandler(event
): void
Event listener for the custom DOM events used by the event bus, bound to this instance.
Parameters
Name | Type |
---|---|
event | CustomEvent <any > |
Returns
void
Defined in
packages/core/src/page/manager/ClientPageManager.ts:38
_clearComponentState
▸ _clearComponentState(options
): void
The method clear state on current rendered component to DOM.
Parameters
Name | Type | Description |
---|---|---|
options | RouteOptions | The current route options. |
Returns
void
Inherited from
AbstractPageManager._clearComponentState
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:757
_constructManagedPageValue
▸ Protected
_constructManagedPageValue(controller
, view
, route
, options
, params
, controllerInstance
, decoratedController
, viewInstance
): ManagedPage
Parameters
Name | Type |
---|---|
controller | RouteController |
view | unknown |
route | AbstractRoute <string | RoutePathExpression > |
options | RouteOptions |
params | RouteParams |
controllerInstance | Controller <PageState , RouteParams , PageState > |
decoratedController | ControllerDecorator <{}, {}, {}> |
viewInstance | unknown |
Returns
Inherited from
AbstractPageManager._constructManagedPageValue
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:249
_deactivateController
▸ Protected
_deactivateController(): Promise
<void
>
Deactivate last managed instance of controller only If controller was activated.
Returns
Promise
<void
>
Inherited from
AbstractPageManager._deactivateController
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:695
_deactivateExtensions
▸ Protected
_deactivateExtensions(): Promise
<void
>
Deactivate extensions for last managed instance of controller only if they were activated.
Returns
Promise
<void
>
Inherited from
AbstractPageManager._deactivateExtensions
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:706
_deactivatePageSource
▸ Protected
_deactivatePageSource(): Promise
<void
>
Deactivate page source so call deactivate method on controller and his extensions.
Returns
Promise
<void
>
Inherited from
AbstractPageManager._deactivatePageSource
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:681
_destroyController
▸ Protected
_destroyController(): Promise
<void
>
Destroy last managed instance of controller.
Returns
Promise
<void
>
Inherited from
AbstractPageManager._destroyController
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:730
_destroyExtensions
▸ Protected
_destroyExtensions(): Promise
<void
>
Destroy extensions for last managed instance of controller.
Returns
Promise
<void
>
Inherited from
AbstractPageManager._destroyExtensions
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:743
_destroyPageSource
▸ Protected
_destroyPageSource(): Promise
<void
>
Destroy page source so call destroy method on controller and his extensions.
Returns
Promise
<void
>
Inherited from
AbstractPageManager._destroyPageSource
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:718
_getInitialManagedPage
▸ Protected
_getInitialManagedPage(): ManagedPage
Clear value from managed page.
Returns
Inherited from
AbstractPageManager._getInitialManagedPage
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:306
_getLoadedControllerState
▸ Protected
_getLoadedControllerState(): Promise
<{}>
Load controller state from managed instance of controller.
Returns
Promise
<{}>
Inherited from
AbstractPageManager._getLoadedControllerState
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:489
_getLoadedExtensionsState
▸ Protected
_getLoadedExtensionsState(controllerState?
): Promise
<UnknownParameters
>
Load extensions state from managed instance of controller.
Parameters
Name | Type |
---|---|
controllerState? | UnknownParameters |
Returns
Promise
<UnknownParameters
>
Inherited from
AbstractPageManager._getLoadedExtensionsState
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:505
_getUpdatedControllerState
▸ Protected
_getUpdatedControllerState(): {} | Promise
<{}>
Return updated controller state for current page controller.
Returns
{} | Promise
<{}>
Inherited from
AbstractPageManager._getUpdatedControllerState
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:625
_getUpdatedExtensionsState
▸ Protected
_getUpdatedExtensionsState(controllerState?
): Promise
<UnknownParameters
>
Return updated extensions state for current page controller.
Parameters
Name | Type |
---|---|
controllerState? | UnknownParameters |
Returns
Promise
<UnknownParameters
>
Inherited from
AbstractPageManager._getUpdatedExtensionsState
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:641
_handleEventWithController
▸ _handleEventWithController(prefix
, method
, data
): boolean
Attempts to handle the currently processed event bus custom DOM event
using the current controller. The method returns true
if the
event is handled by the controller.
Parameters
Name | Type | Description |
---|---|---|
prefix | string | - |
method | string | The name of the method the current controller should use to process the currently processed event bus custom DOM event. |
data | UnknownParameters | The custom event's data. |
Returns
boolean
true
if the event has been handled by the
controller, false
if the controller does not have a
method for processing the event.
Defined in
packages/core/src/page/manager/ClientPageManager.ts:215
_handleEventWithExtensions
▸ _handleEventWithExtensions(prefix
, method
, data
): boolean
Attempts to handle the currently processed event bus custom DOM event
using the registered extensions of the current controller. The method
returns true
if the event is handled by the controller.
Parameters
Name | Type | Description |
---|---|---|
prefix | string | - |
method | string | The name of the method the current controller should use to process the currently processed event bus custom DOM event. |
data | UnknownParameters | The custom event's data. |
Returns
boolean
true
if the event has been handled by one of
the controller's extensions, false
if none of the
controller's extensions has a method for processing the event.
Defined in
packages/core/src/page/manager/ClientPageManager.ts:251
_hasOnlyUpdate
▸ Protected
_hasOnlyUpdate(controller
, view
, options
): boolean
Return true if manager has to update last managed controller and view.
Parameters
Name | Type |
---|---|
controller | RouteController |
view | unknown |
options | RouteOptions |
Returns
boolean
Inherited from
AbstractPageManager._hasOnlyUpdate
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:773
_initController
▸ Protected
_initController(): Promise
<void
>
Initializes managed instance of controller with the provided parameters.
Returns
Promise
<void
>
Inherited from
AbstractPageManager._initController
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:402
_initExtensions
▸ Protected
_initExtensions(): Promise
<void
>
Initialize extensions for managed instance of controller with the provided parameters.
Returns
Promise
<void
>
Inherited from
AbstractPageManager._initExtensions
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:417
_initPageSource
▸ Protected
_initPageSource(): Promise
<void
>
Initialize page source so call init method on controller and his extensions.
Returns
Promise
<void
>
Inherited from
AbstractPageManager._initPageSource
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:387
_loadPageSource
▸ Protected
_loadPageSource(): Promise
<void
| PageData
>
Load page source so call load method on controller and his extensions. Merge loaded state and render it.
Returns
Promise
<void
| PageData
>
Inherited from
AbstractPageManager._loadPageSource
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:447
_onChangeStateHandler
▸ _onChangeStateHandler(state
): void
On change event handler set state to view.
Parameters
Name | Type |
---|---|
state | UnknownParameters |
Returns
void
Defined in
packages/core/src/page/manager/ClientPageManager.ts:276
_onCustomEventHandler
▸ _onCustomEventHandler(event
): void
Custom DOM event handler.
The handler invokes the event listener in the active controller, if such listener is present. The name of the controller's listener method is created by turning the first symbol of the event's name to upper case, and then prefixing the result with the 'on' prefix.
For example: for an event named 'toggle' the controller's listener would be named 'onToggle'.
The controller's listener will be invoked with the event's data as an argument.
Parameters
Name | Type | Description |
---|---|---|
event | CustomEvent <any > | The encountered event bus DOM event. |
Returns
void
Defined in
packages/core/src/page/manager/ClientPageManager.ts:151
_parseCustomEvent
▸ _parseCustomEvent(event
): Object
Extracts the details of the provided event bus custom DOM event, along with the expected name of the current controller's method for intercepting the event.
Parameters
Name | Type | Description |
---|---|---|
event | CustomEvent <any > | The encountered event bus custom DOM event. |
Returns
Object
The event's details.
Name | Type |
---|---|
data | any |
eventName | string |
method | string |
prefix | string |
Defined in
packages/core/src/page/manager/ClientPageManager.ts:188
_runPostManageHandlers
▸ Protected
_runPostManageHandlers(previousManagedPage
, action
): Promise
<unknown
>
Parameters
Name | Type |
---|---|
previousManagedPage | ManagedPage |
action | PageAction |
Returns
Promise
<unknown
>
Inherited from
AbstractPageManager._runPostManageHandlers
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:813
_runPreManageHandlers
▸ Protected
_runPreManageHandlers(actualManagedPage
, action
): Promise
<unknown
>
Parameters
Name | Type |
---|---|
actualManagedPage | ManagedPage |
action | PageAction |
Returns
Promise
<unknown
>
Inherited from
AbstractPageManager._runPreManageHandlers
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:792
_setRestrictedPageStateManager
▸ _setRestrictedPageStateManager(extension
, extensionState
): void
Set page state manager to extension which has restricted rights to set global state.
Parameters
Name | Type |
---|---|
extension | Extension <{}, {}, {}> |
extensionState | UnknownParameters |
Returns
void
Inherited from
AbstractPageManager._setRestrictedPageStateManager
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:346
_storeManagedPageSnapshot
▸ Protected
_storeManagedPageSnapshot(): void
Creates a cloned version of currently managed page and stores it in a helper property. Snapshot is used in manager handlers to easily determine differences between the current and the previous state.
Returns
void
Inherited from
AbstractPageManager._storeManagedPageSnapshot
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:285
_stripManagedPageValueForPublic
▸ Protected
_stripManagedPageValueForPublic(value
): Object
Removes properties we do not want to propagate outside of the page manager
Parameters
Name | Type | Description |
---|---|---|
value | ManagedPage | The managed page object to strip down |
Returns
Object
Name | Type |
---|---|
controller | RouteController |
options | RouteOptions |
params | RouteParams |
route | AbstractRoute <string | RoutePathExpression > |
view | unknown |
Inherited from
AbstractPageManager._stripManagedPageValueForPublic
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:336
_switchToPageStateManager
▸ Protected
_switchToPageStateManager(): void
Iterates over extensions of current controller and switches each one to pageStateManager and clears their partial state.
Returns
void
Inherited from
AbstractPageManager._switchToPageStateManager
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:434
_switchToPageStateManagerAfterLoaded
▸ _switchToPageStateManagerAfterLoaded(extension
, extensionState
): void
For defined extension switches to pageStageManager and clears partial state after extension state is loaded.
Parameters
Name | Type |
---|---|
extension | Extension <{}, {}, {}> |
extensionState | UnknownParameters |
Returns
void
Inherited from
AbstractPageManager._switchToPageStateManagerAfterLoaded
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:367
_updatePageSource
▸ Protected
_updatePageSource(): Promise
<void
| PageData
>
Update page source so call update method on controller and his extensions. Merge updated state and render it.
Returns
Promise
<void
| PageData
>
Inherited from
AbstractPageManager._updatePageSource
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:584
destroy
▸ destroy(): Promise
<void
>
Finalization callback, called when the page manager is being discarded. This usually happens when the page is hot-reloaded at the client side.
Returns
Promise
<void
>
Overrides
Defined in
packages/core/src/page/manager/ClientPageManager.ts:126
getViewController
▸ Protected
getViewController(route
): Promise
<{ controller
: RouteController
; view
: RouteView
}>
Parameters
Name | Type |
---|---|
route | AbstractRoute <string | RoutePathExpression > |
Returns
Promise
<{ controller
: RouteController
; view
: RouteView
}>
Inherited from
AbstractPageManager.getViewController
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:837
init
▸ init(): void
Initializes the page manager.
Returns
void
Overrides
Defined in
packages/core/src/page/manager/ClientPageManager.ts:95
manage
▸ manage(«destructured»
): Promise
<void
| PageData
>
Starts to manage the provided controller and its view. The manager stops the management of any previously managed controller and view.
The controller and view will be initialized and rendered either into the UI (at the client-side) or to the response to send to the client (at the server-side).
Parameters
Name | Type |
---|---|
«destructured» | ManageArgs |
Returns
Promise
<void
| PageData
>
A promise that will resolve to information about the rendered page.
The status
will contain the HTTP status code to send to the
client (at the server side) or determine the type of error page
to navigate to (at the client side).
Overrides
Defined in
packages/core/src/page/manager/ClientPageManager.ts:109
postManage
▸ postManage(): void
Called by router after currently managed route is resolved.
Returns
void
Inherited from
AbstractPageManager.postManage
Defined in
packages/core/src/page/manager/AbstractPageManager.ts:227
preManage
▸ preManage(): Promise
<void
>
Pre manage handler, should be called and awaited before tryint to handle new route handler. This pre manage takes care of canceling any currently executed route handlers and returns promise which is resolved when previous page finished loading (even if it got canceled).
Returns
Promise
<void
>