中间件模式

代码示例

const middlewareA = next => {
  return options => {
    // before
    next(options)
    // after
  }
}
const middlewareB = next => {
  return options => {
    // before
    next(options)
    // after
  }
}

const p = f => middlewareB(middlewareA(f))
const a = p(options => console.log(options))
a(123)

你可能感兴趣的:(中间件模式)