new (require("bajaux/lifecycle/WidgetManager"))(params)
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
params |
object |
Properties
|
- Since:
-
- Niagara 4.10
Methods
-
buildContext(params)
-
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.Parameters:
Name Type Description paramsmodule:bajaux/lifecycle/WidgetManager~BuildParams Returns:
- Type
- Promise.<module:bajaux/lifecycle/WidgetManager~BuildContext>
-
buildFor(params [, widget])
-
Instantiates, initializes, and loads a value into a new Widget as defined
by the input parameters.Parameters:
Name Type Argument Description paramsmodule:bajaux/lifecycle/WidgetManager~BuildParams widgetmodule:bajaux/Widget <optional>
if present, skip the instantiation
and just initialize/load the given widget instance.Returns:
resolves to the widget after it
has been initialized and loaded.- Type
- Promise.<module:bajaux/Widget>
-
deriveConfiguredConstructor(params)
-
Parameters:
Name Type Description paramsmodule:bajaux/lifecycle/WidgetManager~BuildParams Returns:
the constructor, as configured via
thetypeparameter, if present; otherwise undefined. Override to
define other methods of examining params to derive a directly-configured
constructor.- Type
- function | Promise.<function()>
-
destroy(widget)
-
Destroy the widget.
Parameters:
Name Type Description widgetmodule:bajaux/Widget Returns:
- Type
- Promise
-
error(err)
-
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.
Parameters:
Name Type Description errError 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)
-
Initialize the widget into the DOM element as specified in the build
context.Parameters:
Name Type Description widgetmodule:bajaux/Widget buildContextmodule:bajaux/lifecycle/WidgetManager~BuildContext Returns:
- Type
- Promise
-
installHooks(hooks)
-
Install hooks to be invoked at various stages of a widget lifecycle.
Parameters:
Name Type Description hooksmodule:bajaux/lifecycle/WidgetManager~BuildHooks -
instantiate(buildContext)
-
Create a new Widget instance from the build context. If no widget
constructor was able to be determined, default to aToStringWidget.Parameters:
Name Type Description buildContextmodule:bajaux/lifecycle/WidgetManager~BuildContext Returns:
- Type
- module:bajaux/Widget | Promise.<module:bajaux/Widget>
-
load(widget, buildContext)
-
Load the value from the build context into the widget.
Parameters:
Name Type Description widgetmodule:bajaux/Widget buildContextmodule:bajaux/lifecycle/WidgetManager~BuildContext Returns:
- Type
- Promise
-
makeFor(params)
-
Resolves a new Widget instance as defined by the input parameters, but
does not initialize or load it anywhere.Parameters:
Name Type Description paramsmodule:bajaux/lifecycle/WidgetManager~BuildParams Returns:
- Type
- Promise.<module:bajaux/Widget>
-
resolveConstructor(params)
-
Parameters:
Name Type Description paramsmodule: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)
-
Parameters:
Name Type Description paramsmodule:bajaux/lifecycle/WidgetManager~BuildParams Returns:
the constructor resolved from the registry.
By default, do a simple lookup byparams.value; override to define how
registry lookups are performed.- Type
- Promise.<function()>
Type Definitions
-
BuildContext
-
Object describing the configuration needed to construct, initialize, and
load a Widget in a DOM element.Type:
- Object
Properties:
Name Type Argument Description widgetConstructorfunction <optional>
Widget constructor to instantiate.
If no constructor could be found it is up to the WidgetManager to decide
whether to instantiate a default Widget type or to reject.constructorParamsobject params object to pass to the Widget
constructorinitializeParamsObject <optional>
params object to pass to the
initialize() methodlayoutParamsObject <optional>
params object to pass to the layout()
methodloadParamsObject <optional>
params object to pass to the load() method
domstring | HTMLElement | JQuery | * DOM element in which to build a
Widget. Will be translated by theWidgetManagerto an appropriate type
for the Widget.value* <optional>
the value to load into the Widget.
nullis an
acceptable loadable value. Ifundefined, no loading should be performed.dataobject any additional data passed by the caller into the
WidgetManageras thedataproperty. This will be passed through the
build lifecycle untouched. Most useful when using lifecycle hooks to add
functionality to theWidgetManagerinstance. -
BuildHooks}
-
Object describing hooks to be invoked at various points in a widget's
lifecycle. Each hook will be invoked withwidgetandbuildContext
arguments.Type:
- Object
Properties:
Name Type Argument Description instantiatedfunction <optional>
called immediately after a widget is constructed
preInitializefunction <optional>
called before
initialize()is calledpostInitializefunction <optional>
called after
initialize()completespreLoadfunction <optional>
called before
load()is calledpostLoadfunction <optional>
called after
load()completeserrormodule:bajaux/lifecycle/WidgetManager~error <optional>
called when
a widget encounters an error -
BuildParams
-
Object describing the parameters that can be passed to
WidgetManagerto
define a build context. Subclasses ofWidgetManagermay support
additional parameters.Type:
- Object
Properties:
Name Type Argument Description typeString | function <optional>
a
bajaux/Widgetsubclass constructor
function - if given, an instance of that Widget will always be
instantiated instead of dynamically looked up from thevalue. You can
also use a RequireJS module ID that resolves to aWidgetsubclass
constructor.value* <optional>
the value to be loaded into the new widget, if
applicable.domstring | HTMLElement | JQuery | * <optional>
the DOM element in which the
new widget should be initialized, if applicable.propertiesObject <optional>
the bajaux Properties the new widget
should have.enabledBoolean <optional>
set to
falseto cause the new widget to be
disabled. Not used for lookups.readonlyBoolean <optional>
set to
trueto cause the new widget to be
readonly. Not used for lookups.formFactorsString | Array.<String> <optional>
the possible form factors
the new widget should have. The created widget could match any of these
form factors depending on what is registered in the database. If no widget
is found that supports any of these form factors, then no widget will be
created (even if one is present that supports a different form factor). If
no form factor is given, then the widget created could be of any form
factor.formFactorString <optional>
same as a
formFactorsarray of length 1.hooksmodule:bajaux/lifecycle/WidgetManager~BuildHooks <optional>
any
hooks you wish to run at various stages in this widget's lifecycle. They
will run immediately after any installed hooks.