javascript - 任何设计模式都可以替换 javascript 中的 promise/then 链?
问题描述
现在我正在使用 Promise/then 来设计我的代码(类中的部分代码),如下所示:
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)
)
但我认为它对性能不是很好。所以我想找一些东西来代替这段代码,我试过责任链。但这似乎很重。你能否建议一些好的方法来代替它。提前致谢!
解决方案
推荐阅读
- android - 计算早晚时间,然后与给定时间比较
- javascript - 我可以使用 pkg 或类似的东西将 MongoDB 与 node js 打包吗?
- c++ - 将`std::condition_variable`放入未实例化的结构中?
- azure-resource-manager - 将存储帐户连接字符串传递给密钥保管库
- android - 如何在 TextInputLayout 中水平居中“标签提示”?
- java - 以编程方式使用 Kubernetes pod 内存
- java - PHP exec 返回状态 1 但为空数组
- c# - Treeview TextBlock 中的动态路径
- android-studio - 使用 mvvm 时如何从房间数据库中检索项目?
- freemarker - 如何在 FreeMarker 中编写系列?