I am not strong with RxJS so am looking for guidance on how best to chain a sequence of simple non http.get etc. functions in Angular so that they happen in a synchronous fashion.
E.g. what is the 'best' way to run these in sequence in a component?
function1() {
setTimeout(function(){ alert("Hello 1"); }, 3000);
}
function2() {
setTimeout(function(){ alert("Hello 2"); }, 6000);
}
function3() {
setTimeout(function(){ alert("Hello 3"); }, 1000);
}
function4() {
setTimeout(function(){ alert("Hello 4"); }, 750);
}
If you have async call, you can look for forkJoin
from rxjs
.
Here is the sample demo - https://stackblitz.com/edit/typescript-bqxg9x
Reference - https://www.learnrxjs.io/operators/combination/forkjoin.html
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments