Skip to main content

Abstract Class: AbstractExtension<S, R, SS>

Defined in: packages/core/src/extension/AbstractExtension.ts:11

Abstract extension

Extends​

Type Parameters​

S​

S extends PageState = { }

R​

R extends RouteParams = { }

SS​

SS extends S = S

Indexable​

[key: string | number | symbol]: any

Constructors​

Constructor​

new AbstractExtension<S, R, SS>(): AbstractExtension<S, R, SS>

Returns​

AbstractExtension<S, R, SS>

Inherited from​

Extension.constructor

Properties​

_pageStateManager?​

protected optional _pageStateManager: PageStateManager<SS>

Defined in: packages/core/src/extension/AbstractExtension.ts:24

State manager.


_partialStateSymbol​

protected _partialStateSymbol: symbol

Defined in: packages/core/src/extension/AbstractExtension.ts:30


_usingStateManager​

protected _usingStateManager: boolean = false

Defined in: packages/core/src/extension/AbstractExtension.ts:29

Flag indicating whether the PageStateManager should be used instead of partial state.


params​

params: R

Defined in: packages/core/src/extension/AbstractExtension.ts:39

The route parameters extracted from the current route.


status​

status: number = 200

Defined in: packages/core/src/extension/AbstractExtension.ts:35

The HTTP response code to send to the client.


$dependencies​

static $dependencies: Dependencies

Defined in: packages/core/src/extension/AbstractExtension.ts:17

Overrides​

Extension.$dependencies


$name?​

static optional $name: string

Defined in: packages/core/src/extension/AbstractExtension.ts:16

Overrides​

Extension.$name

Methods​

activate()​

activate(): void | Promise<void>

Defined in: packages/core/src/extension/AbstractExtension.ts:58

Callback for activating the extension in the UI. This is the last method invoked during controller (and extensions) initialization, called after all the promises returned from the Extension#load method have been resolved and the controller has configured the meta manager.

The extension may register any React and DOM event listeners in this method. The extension may start receiving event bus event after this method completes.

Returns​

void | Promise<void>

Overrides​

Extension.activate


beginStateTransaction()​

beginStateTransaction(): void

Defined in: packages/core/src/extension/AbstractExtension.ts:109

Starts queueing state patches off the controller state. While the transaction is active every setState call has no effect on the current state.

Note that call to getState after the transaction has begun will return state as it was before the transaction.

Returns​

void

Overrides​

Extension.beginStateTransaction


cancelStateTransaction()​

cancelStateTransaction(): void

Defined in: packages/core/src/extension/AbstractExtension.ts:127

Cancels ongoing state transaction. Uncommitted state changes are lost.

Returns​

void

Overrides​

Extension.cancelStateTransaction


clearPartialState()​

clearPartialState(): void

Defined in: packages/core/src/extension/AbstractExtension.ts:155

Clears the current partial state of the extension and sets it value to empty object.

Returns​

void

Overrides​

Extension.clearPartialState


commitStateTransaction()​

commitStateTransaction(): void

Defined in: packages/core/src/extension/AbstractExtension.ts:118

Applies queued state patches to the controller state. All patches are squashed and applied with one setState call.

Returns​

void

Overrides​

Extension.commitStateTransaction


deactivate()​

deactivate(): void | Promise<void>

Defined in: packages/core/src/extension/AbstractExtension.ts:65

Callback for deactivating the extension in the UI. This is the first method invoked during extension deinitialization. This usually happens when the user navigates to a different URL.

This method is the lifecycle counterpart of the Extension#activate method.

The extension should deregister listeners registered and release all resources obtained in the Extension#activate method.

Returns​

void | Promise<void>

Overrides​

Extension.deactivate


destroy()​

destroy(): void | Promise<void>

Defined in: packages/core/src/extension/AbstractExtension.ts:51

Finalization callback, called when the controller is being discarded by the application. This usually happens when the user navigates to a different URL.

This method is the lifecycle counterpart of the Extension#init method.

The extension should release all resources obtained in the Extension#init method. The extension must release any resources that might not be released automatically when the extensions's instance is destroyed by the garbage collector.

Returns​

void | Promise<void>

Overrides​

Extension.destroy


getAllowedStateKeys()​

getAllowedStateKeys(): keyof S[]

Defined in: packages/core/src/extension/AbstractExtension.ts:204

Returns array of allowed state keys for extension.

Returns​

keyof S[]

Overrides​

Extension.getAllowedStateKeys


getHttpStatus()​

getHttpStatus(): number

Defined in: packages/core/src/extension/AbstractExtension.ts:197

Returns​

number

Inherit Doc​


getPartialState()​

getPartialState(): Partial<SS>

Defined in: packages/core/src/extension/AbstractExtension.ts:148

Returns the current partial state of the extension.

Returns​

Partial<SS>

The current partial state of the extension.

Overrides​

Extension.getPartialState


getRouteParams()​

getRouteParams(): R

Defined in: packages/core/src/extension/AbstractExtension.ts:169

Returns the current route parameters.

Returns​

R

The current route parameters.

Overrides​

Extension.getRouteParams


getState()​

getState(): SS

Defined in: packages/core/src/extension/AbstractExtension.ts:98

Returns the current state of the controller using this extension.

Returns​

SS

The current state of the controller.

Overrides​

Extension.getState


init()​

init(): void | Promise<void>

Defined in: packages/core/src/extension/AbstractExtension.ts:44

Callback for initializing the controller extension after the route parameters have been set on this extension.

Returns​

void | Promise<void>

Overrides​

Extension.init


load()​

load(): S | Promise<S>

Defined in: packages/core/src/extension/AbstractExtension.ts:72

Callback the extension uses to request the resources it needs to render its related parts of the view. This method is invoked after the Extension#init method.

The extension should request all resources it needs in this method, and represent each resource request as a promise that will resolve once the resource is ready for use (these can be data fetched over HTTP(S), database connections, etc).

The method must return a plain flat object. The field names of the object identify the resources being fetched and prepared, each value must be either the resource (e.g. view configuration or a value retrieved synchronously) or a Promise that will resolve to the resource.

The IMA will use the object to set the state of the controller.

Any returned promise that gets rejected will redirect the application to the error page. The error page that will be used depends on the status code of the error.

Returns​

S | Promise<S>

A map object of promises resolved when all resources the controller requires are ready. The resolved values will be pushed to the controller's state.

Overrides​

Extension.load


setPageStateManager()​

setPageStateManager(pageStateManager?): void

Defined in: packages/core/src/extension/AbstractExtension.ts:176

Sets the state manager used to manage the controller's state..

Parameters​

pageStateManager?​

PageStateManager<SS>

The current state manager to use.

Returns​

void

Overrides​

Extension.setPageStateManager


setPartialState()​

setPartialState(partialStatePatch): void

Defined in: packages/core/src/extension/AbstractExtension.ts:136

Patches the partial state of the extension. The extension is able during its load and update phase receive state from active controller using this extension and from previously loaded/updated extensions.

Parameters​

partialStatePatch​

S

Patch of the controller's state to apply.

Returns​

void

Overrides​

Extension.setPartialState


setRouteParams()​

setRouteParams(params): void

Defined in: packages/core/src/extension/AbstractExtension.ts:162

Sets the current route parameters. This method is invoked before the Extension#init method.

Parameters​

params​

R = ...

The current route parameters.

Returns​

void

Overrides​

Extension.setRouteParams


setState()​

setState<K>(statePatch): void

Defined in: packages/core/src/extension/AbstractExtension.ts:89

Patches the state of the controller using this extension by using the provided object by copying the provided patch object fields to the controller's state object.

Note that the state is not patched recursively but by replacing the values of the top-level fields of the state object.

Note that the extension may modify only the fields of the state that it has specified by its Extension#getAllowedStateKeys method.

Type Parameters​

K​

K extends string | number | symbol

Parameters​

statePatch​

Patch of the controller's state to apply.

S | Pick<S, K> | null

Returns​

void

Overrides​

Extension.setState


switchToPartialState()​

switchToPartialState(): void

Defined in: packages/core/src/extension/AbstractExtension.ts:190

Disables using PageStateManager for getting state.

Returns​

void

Overrides​

Extension.switchToPartialState


switchToStateManager()​

switchToStateManager(): void

Defined in: packages/core/src/extension/AbstractExtension.ts:183

Enables using PageStateManager for getting state.

Returns​

void

Overrides​

Extension.switchToStateManager


update()​

update(prevParams): S | Promise<S>

Defined in: packages/core/src/extension/AbstractExtension.ts:82

Callback for updating the extension after a route update. This method is invoked if the current route has the onlyUpdate flag set to true and the current controller and view match those used by the previously active route, or, the onlyUpdate option of the current route is a callback and returned true.

The method must return an object with the same semantics as the result of the Extension#load method. The controller's state will then be patched by the returned object.

The other extension lifecycle callbacks (Extension#init, Extension#load, Extension#activate, Extension#deactivate, Extension#deinit) are not call in case this method is used.

Parameters​

prevParams​

R = ...

Previous route parameters.

Returns​

S | Promise<S>

A map object of promises resolved when all resources the controller requires are ready. The resolved values will be pushed to the controller's state.

Overrides​

Extension.update