angular - need to update this implementation with promise chaining -
i have following method in viewmodelbuilder
class:
async buildviewmodel(request) { const bsm = this.getblogsearchmetadata(); await this.getblogpostsearchresults(request); await bsm; return this.vm; }
this original implementation designed allow getblogsearchmetadata()
, getblogpostsearchresults(request)
execute @ same time. both set properties on this.vm , upon completion of both methods, buildviewmodel
return this.vm.
i have new requirement promise chaining needs used in method. this.getblogsearchmetadata() needs return first , then() promise chain should call this.getblogpostsearchresults(request)
request values set based on response this.getblogsearchmetadata()
.
the method code provided above reflects current implementation. enough code describe specific changes can make code support new requirement? both subfunctions in method marked async keyword.
i have new requirement promise chaining needs used in method. this.getblogsearchmetadata() needs return first , then() promise chain should call this.getblogpostsearchresults(request)
simply await this.getblogsearchmetadata()
async buildviewmodel(request) { // await const result = await this.getblogsearchmetadata(); // can use `result` await this.getblogpostsearchresults(request); return this.vm; }
Comments
Post a Comment