You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need a function to wrap any function so the execution is deferred until all promise-arguments are fulfilled. So this code
getNumber(function(num) {
var result = Math.pow(num);
heavyCheck(result, function(isValid) {
console.log("Valid:", isValid);
});
});
Can be written like this:
heavyCheck = promiserize(heavyCheck);
console.log = promiserize(console.log);
var result = getNumber();
var isValid = heavyCheck(result);
console.log(isValid);
result is a promise isValid is a promise heavyCheck will wait until result is fulfilled then will perfom it's async operation and will return a promise isValid will be binded to this promise so when the returned promise is resolved or rejected isValid will be too. console.log will wait until isValid is fulfilled
The text was updated successfully, but these errors were encountered:
We need a function to wrap any function so the execution is deferred until all promise-arguments are fulfilled. So this code
Can be written like this:
result
is a promiseisValid
is a promiseheavyCheck
will wait untilresult
is fulfilled then will perfom it's async operation and will return a promiseisValid
will be binded to this promise so when the returned promise is resolved or rejectedisValid
will be too.console.log
will wait untilisValid
is fulfilledThe text was updated successfully, but these errors were encountered: