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: |
Description
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(); foo.ready.then(...);
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
comment:2 Changed 10 years ago by
Milestone: | future → 2.0 |
---|
comment:6 Changed 7 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
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 https://github.com/ibm-js/delite. 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() myWidget.store = myStore; // triggers something async, ex: loading data over XHR
onLoadDeferred is the de-facto standard in widgets for an attribute telling when the widget has finished initializing.