Sequential code execution in angular/ typescript

后端 未结 7 2202
醉梦人生
醉梦人生 2021-01-01 06:02

How can I make my code run sequentially? For example,

  1. If I have a for loop which gets some data from a service, I want the n+1 iteration to run

7条回答
  •  渐次进展
    2021-01-01 06:09

    I suggest adapting it to use the zip "combining operator" from rxjs:

    http://reactivex.io/documentation/operators/zip.html

    EDIT: here is an example: https://www.learnrxjs.io/operators/combination/zip.html

    Although in your case you would have to pass it as an array probably ( zipArray).

提交回复
热议问题