Currently, I am working with Angular and CoffeeScript. Within my codebase, there are three functions -
getSomeData1(), getSomeData2(), getSomeData3()
that need to be executed sequentially. The current implementation works perfectly for this requirement.
getSomeData1: ->
@http.get("someRestUrl1")
.success((data) =>
getSomeData2()
getSomeData2: ->
@http.get("someRestUrl2")
.success((data) =>
getSomeData3()
getSomeData3: ->
@http.get("someRestUrl3")
To enhance readability and improve the understanding of the sequential operations, I aim to consolidate all these functions in one place. Something along the lines of:
getSomeData1()
.then(getSomeData2())
.then(getSomeData3())
This proposed structure would significantly aid in clarifying the sequence of actions being performed. Do you have any recommendations on how I can achieve this? Should I consider utilizing $q?