Methods
-
activate()
-
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.
-
deactivate()
-
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. -
destroy()
-
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. -
getAllowedStateKeys()
-
Returns the names of the state fields that may be manipulated by this extension. Manipulations of other fields of the state will be ignored.
Returns:
The names of the state fields that may be manipulated by this extension.
- Type
- Array.<string>
-
getRouteParams()
-
Returns the current route parameters.
Returns:
The current route parameters.
- Type
- Object.<string, string>
-
getState()
-
Returns the current state of the controller using this extension.
Returns:
The current state of the controller.
- Type
- Object.<string, *>
-
init()
-
Callback for initializing the controller extension after the route parameters have been set on this extension.
-
load()
-
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:
A map object of promises resolved when all resources the extension requires are ready. The resolved values will be pushed to the controller's state.
- Type
- Object.<string, (Promise|*)>
-
setPageStateManager(pageStateManager)
-
Sets the state manager used to manage the controller's state..
Parameters:
Name Type Argument Description pageStateManager
PageStateManager <nullable>
The current state manager to use.
-
setRouteParams( [params])
-
Sets the current route parameters. This method is invoked before the
init()
method.Parameters:
Name Type Argument Default Description params
Object.<string, string> <optional>
{} The current route parameters.
-
setState(statePatch)
-
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
Object.<string, *> Patch of the controller's state to apply.
-
update( [prevParams])
-
Callback for updating the extension after a route update. This method is invoked if the current route has the
onlyUpdate
flag set totrue
and the current controller and view match those used by the previously active route, or, theonlyUpdate
option of the current route is a callback and returnedtrue
.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()
,deinit()
) are not call in case this method is used.Parameters:
Name Type Argument Default Description prevParams
Object.<string, string> <optional>
{} Previous route parameters.
Returns:
A map object of promises resolved when all resources the extension requires are ready. The resolved values will be pushed to the controller's state.
- Type
- Object.<string, (Promise|*)>