Skip to main content

Class: ClientPageManager

@ima/core.ClientPageManager

Page manager for controller on the client side.

Hierarchy

Constructors

constructor

new ClientPageManager(pageFactory, pageRenderer, pageStateManager, handlerRegistry, dispatcher, window, eventBus)

Initializes the client-side page manager.

Parameters

NameTypeDescription
pageFactoryPageFactoryFactory used by the page manager to create instances of the controller for the current route, and decorate the controllers and page state managers.
pageRendererPageRendererThe current renderer of the page.
pageStateManagerPageStateManager<{}>-
handlerRegistryPageHandlerRegistryInstance of HandlerRegistry that holds a list of pre-manage and post-manage handlers.
dispatcherDispatcherIMA Dispatcher.
windowWindowThe utility for manipulating the global context and global client-side-specific APIs.
eventBusEventBusThe 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

Dependencies

Defined in

packages/core/src/page/manager/ClientPageManager.ts:42

Methods

#cancelable

Private #cancelable<T>(promise): Promise<T>

Type parameters

Name
T

Parameters

NameType
promiseT

Returns

Promise<T>

Inherited from

AbstractPageManager.#cancelable

Defined in

packages/core/src/page/manager/AbstractPageManager.ts:845


_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:549


_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:563


_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:529


_boundOnCustomEventHandler

Private _boundOnCustomEventHandler(event): void

Event listener for the custom DOM events used by the event bus, bound to this instance.

Parameters

NameType
eventCustomEvent<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

NameTypeDescription
optionsRouteOptionsThe current route options.

Returns

void

Inherited from

AbstractPageManager._clearComponentState

Defined in

packages/core/src/page/manager/AbstractPageManager.ts:753


_constructManagedPageValue

Protected _constructManagedPageValue(controller, view, route, options, params, controllerInstance, decoratedController, viewInstance): ManagedPage

Parameters

NameType
controllerRouteController
viewunknown
routeAbstractRoute<string | RoutePathExpression>
optionsRouteOptions
paramsRouteParams
controllerInstanceController<PageState, RouteParams, PageState>
decoratedControllerControllerDecorator<{}, {}, {}>
viewInstanceunknown

Returns

ManagedPage

Inherited from

AbstractPageManager._constructManagedPageValue

Defined in

packages/core/src/page/manager/AbstractPageManager.ts:245


_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:691


_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:702


_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:677


_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:726


_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:739


_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:714


_getInitialManagedPage

Protected _getInitialManagedPage(): ManagedPage

Clear value from managed page.

Returns

ManagedPage

Inherited from

AbstractPageManager._getInitialManagedPage

Defined in

packages/core/src/page/manager/AbstractPageManager.ts:302


_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:485


_getLoadedExtensionsState

Protected _getLoadedExtensionsState(controllerState?): Promise<UnknownParameters>

Load extensions state from managed instance of controller.

Parameters

NameType
controllerState?UnknownParameters

Returns

Promise<UnknownParameters>

Inherited from

AbstractPageManager._getLoadedExtensionsState

Defined in

packages/core/src/page/manager/AbstractPageManager.ts:501


_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:621


_getUpdatedExtensionsState

Protected _getUpdatedExtensionsState(controllerState?): Promise<UnknownParameters>

Return updated extensions state for current page controller.

Parameters

NameType
controllerState?UnknownParameters

Returns

Promise<UnknownParameters>

Inherited from

AbstractPageManager._getUpdatedExtensionsState

Defined in

packages/core/src/page/manager/AbstractPageManager.ts:637


_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

NameTypeDescription
prefixstring-
methodstringThe name of the method the current controller should use to process the currently processed event bus custom DOM event.
dataUnknownParametersThe 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

NameTypeDescription
prefixstring-
methodstringThe name of the method the current controller should use to process the currently processed event bus custom DOM event.
dataUnknownParametersThe 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

NameType
controllerRouteController
viewunknown
optionsRouteOptions

Returns

boolean

Inherited from

AbstractPageManager._hasOnlyUpdate

Defined in

packages/core/src/page/manager/AbstractPageManager.ts:769


_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:398


_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:413


_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:383


_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:443


_onChangeStateHandler

_onChangeStateHandler(state): void

On change event handler set state to view.

Parameters

NameType
stateUnknownParameters

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

NameTypeDescription
eventCustomEvent<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

NameTypeDescription
eventCustomEvent<any>The encountered event bus custom DOM event.

Returns

Object

The event's details.

NameType
dataany
eventNamestring
methodstring
prefixstring

Defined in

packages/core/src/page/manager/ClientPageManager.ts:188


_runPostManageHandlers

Protected _runPostManageHandlers(previousManagedPage, action): Promise<unknown>

Parameters

NameType
previousManagedPageManagedPage
actionPageAction

Returns

Promise<unknown>

Inherited from

AbstractPageManager._runPostManageHandlers

Defined in

packages/core/src/page/manager/AbstractPageManager.ts:809


_runPreManageHandlers

Protected _runPreManageHandlers(actualManagedPage, action): Promise<unknown>

Parameters

NameType
actualManagedPageManagedPage
actionPageAction

Returns

Promise<unknown>

Inherited from

AbstractPageManager._runPreManageHandlers

Defined in

packages/core/src/page/manager/AbstractPageManager.ts:788


_setRestrictedPageStateManager

_setRestrictedPageStateManager(extension, extensionState): void

Set page state manager to extension which has restricted rights to set global state.

Parameters

NameType
extensionExtension<{}, {}, {}>
extensionStateUnknownParameters

Returns

void

Inherited from

AbstractPageManager._setRestrictedPageStateManager

Defined in

packages/core/src/page/manager/AbstractPageManager.ts:342


_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:281


_stripManagedPageValueForPublic

Protected _stripManagedPageValueForPublic(value): Object

Removes properties we do not want to propagate outside of the page manager

Parameters

NameTypeDescription
valueManagedPageThe managed page object to strip down

Returns

Object

NameType
controllerRouteController
optionsRouteOptions
paramsRouteParams
routeAbstractRoute<string | RoutePathExpression>
viewunknown

Inherited from

AbstractPageManager._stripManagedPageValueForPublic

Defined in

packages/core/src/page/manager/AbstractPageManager.ts:332


_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:430


_switchToPageStateManagerAfterLoaded

_switchToPageStateManagerAfterLoaded(extension, extensionState): void

For defined extension switches to pageStageManager and clears partial state after extension state is loaded.

Parameters

NameType
extensionExtension<{}, {}, {}>
extensionStateUnknownParameters

Returns

void

Inherited from

AbstractPageManager._switchToPageStateManagerAfterLoaded

Defined in

packages/core/src/page/manager/AbstractPageManager.ts:363


_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:580


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

AbstractPageManager.destroy

Defined in

packages/core/src/page/manager/ClientPageManager.ts:126


getViewController

Protected getViewController(route): Promise<{ controller: RouteController ; view: RouteView }>

Parameters

NameType
routeAbstractRoute<string | RoutePathExpression>

Returns

Promise<{ controller: RouteController ; view: RouteView }>

Inherited from

AbstractPageManager.getViewController

Defined in

packages/core/src/page/manager/AbstractPageManager.ts:833


init

init(): void

Initializes the page manager.

Returns

void

Overrides

AbstractPageManager.init

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

NameType
«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

AbstractPageManager.manage

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:223


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>

Inherited from

AbstractPageManager.preManage

Defined in

packages/core/src/page/manager/AbstractPageManager.ts:123