> A Deferred object is returned by the obsolete Promise.defer() method to provide a new promise along with methods to change its state.
> Starting from Gecko 30, this object is obsolete and should not be used anymore. Use the new Promise() constructor instead (or use the above backwards/forwards compatible Deferred function given below). For example, the equivalent of
Seems like it's obsolete. [0]
If you want to write async code, use async / await.
const run = async () => {
const response = await new Promise((resolve, reject) => methodOne(data, (e, res) => e ? reject(e) : resolve(res)));
};
If you spend enough time with fat arrow, it's as easy to read as `function` is. On top of that, IMO it looks cleaner. It also allows you to do scope binding in a different manor which in React is much better.
> Starting from Gecko 30, this object is obsolete and should not be used anymore. Use the new Promise() constructor instead (or use the above backwards/forwards compatible Deferred function given below). For example, the equivalent of
Seems like it's obsolete. [0]
If you want to write async code, use async / await.
If you spend enough time with fat arrow, it's as easy to read as `function` is. On top of that, IMO it looks cleaner. It also allows you to do scope binding in a different manor which in React is much better.This:
becomes this: [0] https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_...