In the OpenUI5 code base, I came across this snippet:
Promise.resolve().then(this._updateTableSizes.bind(this, true));
It looks like the built-in Promise function is used , without an argument passed to it resolve, which takes:
The argument that must be resolved by this promise. It can also be a promise or can then be resolved.
So, since it looks like the promise will simply resolve and call the callback right away then, perhaps an intent similar to :
var self = this;
setTimeout(function() {
self._updateTableSizes.bind(self, true)
}, 0);
... basically, freeing up the JavaScript runtime loop to complete other actions (like rendering), and then back to the callback?
My question is:
Is this a common template? Best practice Are there any advantages / disadvantages for both?