Opened 11 years ago

Closed 7 years ago

#13782 closed enhancement (wontfix)

support async widget creation

Reported by: bill Owned by: bill
Priority: high Milestone: 2.0
Component: Dijit Version: 1.6.1
Keywords: Cc: dante, ben hockey
Blocked By: Blocking:


Allow each widget lifecycle method (postMixinProperties(), buildRendering() etc.) to return a Deferred. If a method returns a Deferred, widget creation will be paused until the Deferred resolves, at which point the subsequent lifecycle methods (ex: postCreate()) will execute. They may also return Deferred's. This is similar to how DOH runs a sequence of test functions.

This means that new FooWidget() will return before the widget is fully initialized. There will need to be a flag to detect when the widget has finished initializing, something like:

var foo = new FooWidget();

It will also require changes to the parser to return a Deferred, and to defer calling startup() on the widgets until they've finished initializing.

Change History (6)

comment:1 Changed 10 years ago by bill

onLoadDeferred is the de-facto standard in widgets for an attribute telling when the widget has finished initializing.

comment:2 Changed 10 years ago by bill

Milestone: future2.0

comment:3 Changed 9 years ago by bill

In [30451]:

Allow for a widget's markupFactory() to return a Promise. The Promise returned by dojo/parser::parse() won't resolve until all widget's promises have resolved. Also, make ContentPanemarkupFactory() return a promise base on the nested parse() call. Together, these changes make sure a parse() call waits for ContentPane's nested parse() calls to complete before calling startup() on any of the widgets.

The change to parser makes markupFactory() a general purpose factory function for widgets, which can even be useful when used programatically. The naming of the function is unfortunate, since it suggests that it's only useful for markup, but I'm reluctant to use a common name like create() since that may already be in use for another purpose.

Also, had to do acrobatics to keep back-compat of the signature of dojo/parser::instantiate().

Fixes #16503, refs #13782 !strict.

comment:4 Changed 9 years ago by bill

In [30473]:

don't created Deferred objects unnecessarily, refs #13782 !strict

comment:5 Changed 9 years ago by bill

In [30514]:

revert unintentional indentation change from [30473], and remove unused dojo/when dependency, refs #13782 !strict

comment:6 Changed 7 years ago by bill

Resolution: wontfix
Status: newclosed

I don't remember why I filed this ticket. I don't see much of a need for it now, which is why I didn't add the feature to So I'm going to close as wontfix.

Deliteful certainly has widgets that load asynchronously, specifically widgets that load from a store, but the asynchronous code is not part of the startup lifecycle routines (render(), postRender(), attachedCallback()). I think that's because the parameters to the widget are handled after creation completes, since that's how custom elements work, for example:

var myWidget = document.createElement("my-widget");  // runs render(), postRender() = myStore; // triggers something async, ex: loading data over XHR
Note: See TracTickets for help on using tickets.