dimanche 26 avril 2020

Any design pattern can replace promise/then chain in javascript?

Now I am using Promise/then to design my code(part of code in class) like below:

Condition.getFromServer()
.then(ContentInfoFromServer =>
    this.foo(para)
)
.then(para =>
    this.bar(para)
)
.then(para =>
    this.jor(para)
)
.then(para =>
    this.dom(para)
)
.then(para =>
    this.pam(para)
)

But I think it is not very good for performance. So I want find something replace this code, I've tried the chain of responsibility. But it seems like so heavy for this. Could you please suggest some good way to replace that. Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire