Answers for "how to implement a promise with daisy chaining in angular"

1

how to implement a promise with daisy chaining in angular

private firstAction():Promise<any> {
  return new Promise<any>(
    (resolve, reject) => { ... }
  );
}
private secondAction():Promise<any> {
  return new Promise<any>(
    (resolve, reject) => { ... }
  );
}
execute() {
  this.firstAction().then(
    (firstResult:any) => this.secondAction().then(
      (secondResult:any) => { ... }
    );
  )
}
Posted by: Guest on September-23-2020
3

promise chaining

new Promise(function(resolve, reject) {

  setTimeout(() => resolve(1), 1000); // (*)

}).then(function(result) { // (**)

  alert(result); // 1
  return result * 2;

}).then(function(result) { // (***)

  alert(result); // 2
  return result * 2;

}).then(function(result) {

  alert(result); // 4
  return result * 2;

});
Posted by: Guest on June-21-2020

Code answers related to "how to implement a promise with daisy chaining in angular"

Code answers related to "Javascript"

Browse Popular Code Answers by Language