javascript - 如何借助 node.js 中的 flow.js(用于异步调用)以 DRY 模式创建模型?

标签 javascript node.js design-patterns redis

例如,

function user(){
    flow.exec(
        function(){
            call a; 
        },
        function(){
            call b;
        }
    );
}

function posts(){
    flow.exec(
        function(){
            call a; 
        },
        function(){
            call c;
        }
    );
}

按照上面的代码,我如何在不同的模型上调用通用函数(调用 a)

最佳答案

function perform(first, second) {
  flow.exec(first, second);
}

function callA() {
  a();
}

function callB() {
  b();
}

perform(callA, callB);

关于javascript - 如何借助 node.js 中的 flow.js(用于异步调用)以 DRY 模式创建模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6508161/

相关文章:

javascript - return false 或 return true 不会跳到 jQuery 中的下一个循环

node.js - Youtube PubSubHubBub 集成

design-patterns - 工厂方法的命名约定是什么?

javascript - Uncaught ReferenceError : webkitNotifications is not defined

Javascript 忽略 document.write 中的标签

javascript - super 代理动态方法类型

node.js - 使用 passport-saml 将 nodejs 配置为 SP,并将 OpenAM 配置为 IDP

node.js - Multer 模块无法启动

java - 多个 API 调用 : Design Patterns

c# - 在 C# 中使用通知的生产者和消费者