A duck-typing interface that defines optional ViewModel methods that the ojModule binding will invoke by convention
- Source:
Methods
-
dispose(info)
-
This method may be implemented by the ViewModel to perform cleanup tasks. Note that this method will be invoked only once before all binding's refernces to the ViewModel are released.
Parameters:
Name Type Description info
Object an object with the following key-value pairs: - 'element' - DOM element where the binding is attached
- 'valueAccessor' - binding's value accessor
- Source:
-
handleActivated(info) → {Promise|undefined}
-
Optional ViewModel method invoked when this ViewModel is about to be used for the View transition
Parameters:
Name Type Description info
Object an object with the following key-value pairs: - 'element' - DOM element where the binding is attached
- 'valueAccessor' - binding's value accessor
- Source:
Returns:
- If the callback returns a Promise, the next phase (attaching DOM) will be delayed until the promise is resolved- Type
- Promise | undefined
-
handleAttached(info)
-
Optional ViewModel method invoked after the View is inserted into the document DOM
Parameters:
Name Type Description info
Object an object with the following key-value pairs: - 'element' - DOM element where the binding is attached
- 'valueAccessor' - binding's value accessor
- 'fromCache ' - a boolean indicating whether the module was retrieved from cache
- Source:
-
handleBindingsApplied(info)
-
Optional ViewModel method invoked after the bidnings are applied on this View. If the current View is retrieved from cache, the bindings will not be re-applied, and this callback will not be invoked.
Parameters:
Name Type Description info
Object an object with the following key-value pairs: - 'element' - DOM element where the binding is attached
- 'valueAccessor' - binding's value accessor
- Source:
-
handleDeactivated(info)
-
Optional ViewModel method invoked when the View/ViewModel combination becomes inactive
Parameters:
Name Type Description info
Object an object with the following key-value pairs: - 'element' - DOM element where the binding is attached
- 'valueAccessor' - binding's value accessor
- Source:
-
handleDetached(info)
-
Optional ViewModel method invoked after the View is removed from the document DOM
Parameters:
Name Type Description info
Object an object with the following key-value pairs: - 'element' - DOM element where the binding is attached
- 'valueAccessor' - binding's value accessor
- 'cachedNodes' - an Array containing cached nodes for the View (if the cache is enabled)
- Source:
-
initialize(info) → {Object|undefined}
-
This method may be implemented on the ViewModel to perform initialization tasks. The method will be invoked only if the ViewModel factory or the AMD module returns a ViewModel instance (as opposed to a constructor function). Note that this method will be invoked only once when the ViewModel is created, i.e. it will not be called when the View is being brought from cache
Parameters:
Name Type Description info
Object an object with the following key-value pairs: - 'element' - DOM element where the binding is attached
- 'valueAccessor' - binding's value accessor
ko.utils.unwrapObservable(info.valueAccessor()).params
if the entire binding value is an observable orko.utils.unwrapObservable(info.valueAccessor().params)
if the bidning value is a plain object literal.- Source:
Returns:
- optional return value that will be used as the new ViewModel instance- Type
- Object | undefined