Constructor
new (require("bajaux/lifecycle/WidgetManager"))(params)
- Source:
- Since:
- Niagara 4.10
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
params |
object |
Properties
|
Methods
buildContext(params) → {Promise.<module:bajaux/lifecycle/WidgetManager~BuildContext>}
- Description:
This method functions as the "starting point" for a Widget build. It
receives the parameters as given by the user, and calculates a build
context to be used during the rest of the initialize/load/destroy
lifecycle.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
params |
module:bajaux/lifecycle/WidgetManager~BuildParams |
Returns:
- Type
- Promise.<module:bajaux/lifecycle/WidgetManager~BuildContext>
buildFor(params, widgetopt) → {Promise.<module:bajaux/Widget>}
- Description:
Instantiates, initializes, and loads a value into a new Widget as defined
by the input parameters.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
params |
module:bajaux/lifecycle/WidgetManager~BuildParams | ||
widget |
module:bajaux/Widget |
<optional> |
if present, skip the instantiation |
Returns:
resolves to the widget after it
has been initialized and loaded.
- Type
- Promise.<module:bajaux/Widget>
deriveConfiguredConstructor(params) → {function|Promise.<function()>}
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
params |
module:bajaux/lifecycle/WidgetManager~BuildParams |
Returns:
the constructor, as configured via
the type parameter, if present; otherwise undefined. Override to
define other methods of examining params to derive a directly-configured
constructor.
- Type
- function | Promise.<function()>
destroy(widget) → {Promise}
- Description:
Destroy the widget.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
widget |
module:bajaux/Widget |
Returns:
- Type
- Promise
error(err) → {Promise}
- Description:
This method is called when an error is encountered with a Widget.
If there is an installed error hook on this manager, it will be invoked.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
err |
Error | the error from the Widget |
Returns:
If an error hook is installed, this will
resolve once the error hook is finished. If no error hook is installed,
this will reject with the provided error.
- Type
- Promise
initialize(widget, buildContext) → {Promise}
- Description:
Initialize the widget into the DOM element as specified in the build
context.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
widget |
module:bajaux/Widget | |
buildContext |
module:bajaux/lifecycle/WidgetManager~BuildContext |
Returns:
- Type
- Promise
installHooks(hooks)
- Description:
Install hooks to be invoked at various stages of a widget lifecycle.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
hooks |
module:bajaux/lifecycle/WidgetManager~BuildHooks |
instantiate(buildContext) → {module:bajaux/Widget|Promise.<module:bajaux/Widget>}
- Description:
Create a new Widget instance from the build context. If no widget
constructor could be determined, default to a
ToStringWidget.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
buildContext |
module:bajaux/lifecycle/WidgetManager~BuildContext |
Returns:
- Type
- module:bajaux/Widget | Promise.<module:bajaux/Widget>
load(widget, buildContext) → {Promise}
- Description:
Load the value from the build context into the widget.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
widget |
module:bajaux/Widget | |
buildContext |
module:bajaux/lifecycle/WidgetManager~BuildContext |
Returns:
- Type
- Promise
makeFor(params) → {Promise.<module:bajaux/Widget>}
- Description:
Resolves a new Widget instance as defined by the input parameters, but
does not initialize or load it anywhere.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
params |
module:bajaux/lifecycle/WidgetManager~BuildParams |
Returns:
- Type
- Promise.<module:bajaux/Widget>
resolveConstructor(params) → {Promise.<(function()|undefined)>}
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
params |
module:bajaux/lifecycle/WidgetManager~BuildParams |
Returns:
resolves the constructor to be
used to instantiate the widget, either as configured via params or as
looked up from the registry.
- Type
- Promise.<(function()|undefined)>
resolveFromRegistry(params) → {Promise.<function()>}
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
params |
module:bajaux/lifecycle/WidgetManager~BuildParams |
Returns:
the constructor resolved from the registry.
By default, do a simple lookup by params.value; override to define how
registry lookups are performed.
- Type
- Promise.<function()>
Type Definitions
BuildContext
- Description:
Object describing the configuration needed to construct, initialize, and
load a Widget in a DOM element.
- Source:
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
widgetConstructor |
function |
<optional> |
Widget constructor to instantiate. |
constructorParams |
object | params object to pass to the Widget |
|
initializeParams |
Object |
<optional> |
params object to pass to the |
layoutParams |
Object |
<optional> |
params object to pass to the layout() |
loadParams |
Object |
<optional> |
params object to pass to the load() method |
dom |
string | HTMLElement | JQuery | * | DOM element in which to build a |
|
value |
* |
<optional> |
the value to load into the Widget. |
data |
object | any additional data passed by the caller into the |
Object describing the configuration needed to construct, initialize, and
load a Widget in a DOM element.
Type:
- Object
BuildHooks}
- Description:
Object describing hooks to be invoked at various points in a widget's
lifecycle. Each hook will be invoked withwidgetandbuildContext
arguments.
- Source:
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
instantiated |
function |
<optional> |
called immediately after a widget is constructed |
preInitialize |
function |
<optional> |
called before |
postInitialize |
function |
<optional> |
called after |
preLoad |
function |
<optional> |
called before |
postLoad |
function |
<optional> |
called after |
error |
module:bajaux/lifecycle/WidgetManager~error |
<optional> |
called when |
Object describing hooks to be invoked at various points in a widget's
lifecycle. Each hook will be invoked with widget and buildContext
arguments.
Type:
- Object
BuildParams
- Description:
Object describing the parameters that can be passed to
WidgetManagerto
define a build context. Subclasses ofWidgetManagermay support
additional parameters.
- Source:
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
type |
String | function |
<optional> |
a |
value |
* |
<optional> |
the value to be loaded into the new widget, if |
dom |
string | HTMLElement | JQuery | * |
<optional> |
the DOM element in which the |
properties |
Object |
<optional> |
the bajaux Properties the new widget |
enabled |
Boolean |
<optional> |
set to |
readonly |
Boolean |
<optional> |
set to |
formFactors |
String | Array.<String> |
<optional> |
the possible form factors |
formFactor |
String |
<optional> |
same as a |
hooks |
module:bajaux/lifecycle/WidgetManager~BuildHooks |
<optional> |
any |
Object describing the parameters that can be passed to WidgetManager to
define a build context. Subclasses of WidgetManager may support
additional parameters.
Type:
- Object