ibm-js/delite — pull request #350 by wkeese (2014-12-19 12:56:56+00:00)
Title: Use ES6 Promise API rather than dojo/Deferred

This PR converts the delite code to use the ES6 promise API, as shimmed by calvinmetcalf#lie. Note that shim could be replaced by any equivalent shim, or by a plugin that only loads the shim if necessary.

This includes one API change: events now have a `setLoadDeferred()` method rather than a `loadDeferred` property. That's because ES6 Promises don't have `resolve()` and `reject()` methods. Probably that function should have a better name, like `setChildInfo()`.

```js
require(["delite/register", "delite/DisplayContainer", "lie/dist/lie", "dojo/request"/*, ...*/],
function (register, DisplayContainer, Promise, request/*, ...*/) {
document.addEventListener("delite-display-load", function(event) {
event.setLoadDeferred(new Promise(function (resolve, reject) {
// build a file name from the destination
request(event.dest+".html", function (data) {
// build a child from the data in the file
var child = a_parse_function(data);
// resolve with the child
resolve({ child: child });
}));
});
});
```

`setLoadDeferred()` parameter is either a plain object, or a thenable (aka Promise).

Internally, the changes to match ES6 Promise spec are:

- Since ES6 Promises have no `cancel()` method, HasDropDown has code to manually cancel.
- You specify the resolve and reject code at the time the promise is created, like in the example above.
- `when(...)` --> `Promise.resolve(...)`

Other notes:

- DisplayContainer's `show()` and `hide()` methods were unnecessarily creating a Deferred. I refactored the code not to do that.