Class: AbstractExtension
@ima/core.AbstractExtension
Abstract extension
Implements
Indexable
▪ [key: PropertyKey
]: any
| EventHandler
| UnknownParameters
Constructors
constructor
• new AbstractExtension()
Properties
_pageStateManager
• Protected
Optional
_pageStateManager: PageStateManager
State manager.
Defined in
packages/core/src/extension/AbstractExtension.ts:19
_partialStateSymbol
• Protected
_partialStateSymbol: symbol
Defined in
packages/core/src/extension/AbstractExtension.ts:25
_usingStateManager
• Protected
_usingStateManager: boolean
= false
Flag indicating whether the PageStateManager should be used instead of partial state.
Defined in
packages/core/src/extension/AbstractExtension.ts:24
params
• params: UnknownParameters
= {}
The route parameters extracted from the current route.
Defined in
packages/core/src/extension/AbstractExtension.ts:34
status
• status: number
= 200
The HTTP response code to send to the client.
Defined in
packages/core/src/extension/AbstractExtension.ts:30
Methods
activate
▸ activate(): void
| Promise
<undefined
>
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 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
<undefined
>
Implementation of
Defined in
packages/core/src/extension/AbstractExtension.ts:51
beginStateTransaction
▸ beginStateTransaction(): void
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
Implementation of
Extension.beginStateTransaction
Defined in
packages/core/src/extension/AbstractExtension.ts:102
cancelStateTransaction
▸ cancelStateTransaction(): void
Cancels ongoing state transaction. Uncommitted state changes are lost.
Returns
void
Implementation of
Extension.cancelStateTransaction
Defined in
packages/core/src/extension/AbstractExtension.ts:120
clearPartialState
▸ clearPartialState(): void
Clears the current partial state of the extension and sets it value to empty object.
Returns
void
Implementation of
Defined in
packages/core/src/extension/AbstractExtension.ts:148
commitStateTransaction
▸ commitStateTransaction(): void
Applies queued state patches to the controller state. All patches are squashed
and applied with one setState
call.
Returns
void
Implementation of
Extension.commitStateTransaction
Defined in
packages/core/src/extension/AbstractExtension.ts:111
deactivate
▸ deactivate(): void
| Promise
<undefined
>
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 activate method.
The extension should deregister listeners registered and release all resources obtained in the activate method.
Returns
void
| Promise
<undefined
>
Implementation of
Defined in
packages/core/src/extension/AbstractExtension.ts:58
destroy
▸ destroy(): void
| Promise
<undefined
>
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 init method.
The extension should release all resources obtained in the 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
<undefined
>
Implementation of
Defined in
packages/core/src/extension/AbstractExtension.ts:44
getAllowedStateKeys
▸ getAllowedStateKeys(): never
[]
Returns array of allowed state keys for extension.
Returns
never
[]
Implementation of
Defined in
packages/core/src/extension/AbstractExtension.ts:197
getHttpStatus
▸ getHttpStatus(): number
Inherit Doc
Returns
number
Defined in
packages/core/src/extension/AbstractExtension.ts:190
getPartialState
▸ getPartialState(): any
Returns the current partial state of the extension.
Returns
any
The current partial state of the extension.
Implementation of
Defined in
packages/core/src/extension/AbstractExtension.ts:141
getRouteParams
▸ getRouteParams(): UnknownParameters
Returns the current route parameters.
Returns
The current route parameters.
Implementation of
Defined in
packages/core/src/extension/AbstractExtension.ts:162
getState
▸ getState(): any
Returns the current state of the controller using this extension.
Returns
any
The current state of the controller.
Implementation of
Defined in
packages/core/src/extension/AbstractExtension.ts:91
init
▸ init(): void
| Promise
<undefined
>
Callback for initializing the controller extension after the route parameters have been set on this extension.
Returns
void
| Promise
<undefined
>
Implementation of
Defined in
packages/core/src/extension/AbstractExtension.ts:39
load
▸ load(): UnknownPromiseParameters
| Promise
<UnknownPromiseParameters
>
Callback the extension uses to request the resources it needs to render its related parts of the view. This method is invoked after the 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
UnknownPromiseParameters
| Promise
<UnknownPromiseParameters
>
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.
Implementation of
Defined in
packages/core/src/extension/AbstractExtension.ts:65
setPageStateManager
▸ setPageStateManager(pageStateManager?
): void
Sets the state manager used to manage the controller's state..
Parameters
Name | Type | Description |
---|---|---|
pageStateManager? | PageStateManager | The current state manager to use. |
Returns
void
Implementation of
Defined in
packages/core/src/extension/AbstractExtension.ts:169
setPartialState
▸ setPartialState(partialStatePatch
): void
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
Name | Type | Description |
---|---|---|
partialStatePatch | UnknownParameters | Patch of the controller's state to apply. |
Returns
void
Implementation of
Defined in
packages/core/src/extension/AbstractExtension.ts:129
setRouteParams
▸ setRouteParams(params?
): void
Sets the current route parameters. This method is invoked before the init method.
Parameters
Name | Type | Description |
---|---|---|
params | Object | The current route parameters. |
Returns
void
Implementation of
Defined in
packages/core/src/extension/AbstractExtension.ts:155
setState
▸ setState(statePatch
): void
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 getAllowedStateKeys method.
Parameters
Name | Type | Description |
---|---|---|
statePatch | UnknownParameters | Patch of the controller's state to apply. |
Returns
void
Implementation of
Defined in
packages/core/src/extension/AbstractExtension.ts:82
switchToPartialState
▸ switchToPartialState(): void
Disables using PageStateManager for getting state.
Returns
void
Implementation of
Extension.switchToPartialState
Defined in
packages/core/src/extension/AbstractExtension.ts:183
switchToStateManager
▸ switchToStateManager(): void
Enables using PageStateManager for getting state.
Returns
void
Implementation of
Extension.switchToStateManager
Defined in
packages/core/src/extension/AbstractExtension.ts:176
update
▸ update(): Object
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 load method. The controller's state will then be patched by the returned object.
The other extension lifecycle callbacks (init, load, activate, deactivate, Extension#deinit) are not call in case this method is used.
Returns
Object
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.