-
Improvement
-
Resolution: Fixed
-
Minor
-
4.0, 4.2
-
MOODLE_400_STABLE, MOODLE_402_STABLE
-
MOODLE_402_STABLE
-
MDL-72609-master -
We should convert the core/pending module to use native Promises.
This does offer a minor risk because we will no longer be returning a jQuery Deferred promise, but a native Promise. This means that:
- there is no fail or done function
- the behaviour on a fail is different to catch
However, I think that it's worth making this change because the behaviour of jQuery promises is counter-intuitive in some cases.
This change also introduces some alternate ways to call the code:
- an observer
- a native-promise-like syntax
The observer takes an existing promise:
const observer = Pending.observe(myExistingPromise, 'Some descriptor (optional)');
|
The native-promise syntax can be used in the same way as a native Promise:
Pending.Promise((resolve, reject) => {
|
getString('ok')
|
.then(okay => {
|
window.console.log(okay);
|
return okay;
|
})
|
.then(resolve)
|
.catch(reject);
|
}, 'mod_myexample/setup:init');
|
- blocks
-
MDL-35595 Javascript unit testing
- Reopened