Node EventEmitter事件队列

var proxy = new events.EventEmitter()
var status = "ready"
var select = function(callback) {
  proxy.once("selected", callback)
  if (status === "ready") {
    status = "pending"
    setTimeout(() => {
      proxy.emit("selected", results)
      status = "ready"
    }, 2000)
  }
}

你可能感兴趣的:(Node EventEmitter事件队列)