Interface: ModuleViewModel

Oracle® JavaScript Extension Toolkit (JET)
9.2.0

F30740-01

QuickNav

ModuleViewModel

Version:
  • 9.2.0
Since:
  • 7.0.0
Module:
  • ojmodule-element

Module usage

See JET Module Loading for an overview of module usage within JET.

Typescript Import Format
//To use this interface, import as below.
import {ModuleViewModel} from "ojs/ojmodule-element";

JET In Typescript

A detailed description of working with JET elements and classes in your typescript project can be found at: JET Typescript Usage.

A duck-typing interface that defines a contract for a view model consumed by the oj-module element.

Methods

canExit(): Promise<void>

This optional method may be implemented on the ViewModel and will be invoked by ModuleRouterAdapter on beforeStateChange event assuming that oj-module is used in conjuction with ModuleRouterAdapter.

This method must return a Promise. When defined the method is invoked before router state change. If the Promise is resolved, then the BaseRouter will continue with the state change, otherwise (Promise rejected) the state change is vetoed and the current router state does not change.

Note, that the method might be called at any time after the view model is created, e.g. before the corresponding view has been connected or bindings have been applied.

Since:
  • 8.0.0

connected(view:Array<Node>): void

This optional method may be implemented on the ViewModel and will be invoked after the View is inserted into the DOM. This method might be called multiple times - after the View is created and inserted into the DOM, after the View is reconnected after being disconnected and after a parent element, oj-module, with attached View is reconnected to the DOM. An array of DOM nodes that represent the connected View will be passed to the callback.
Since:
  • 7.0.0

disconnected(view:Array<Node>): void

This optional method may be implemented on the ViewModel and will be invoked when the View is disconnected from the DOM. This method might be called multiple times - after the View is disconnected from the DOM and after a parent element, oj-module, with attached View is disconnected from the DOM. An array of DOM nodes that represent the disconnected View will be passed to the callback.
Since:
  • 7.0.0

parametersChanged(params:any): void

This optional method may be implemented on the ViewModel and will be invoked by ModuleRouterAdapter on stateChange event assuming that oj-module is used in conjuction with ModuleRouterAdapter.

If the method is present the ModuleRouterAdapter will assume that the view model knows how to handle parameter change. It will not reload the module and re-apply binding. If the method is not present the ModuleRouterAdapter will reload the module and apply the binding upon any parameter change.

Note, that the method might be called at any time after the view model is created, e.g. before the corresponding view has been connected or bindings have been applied.

Since:
  • 8.0.0

transitionCompleted(view:Array<Node>): void

This optional method may be implemented on the ViewModel and invoked after transition to the new View is complete, including any possible animation between the old and the new View. An array of DOM nodes that represent the new View will be passed to the callback.
Since:
  • 7.0.0