0.0.3 • Published 4 years ago

async-event2 v0.0.3

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

example

const AsyncEvent = require('./index')

const asyncEvent = new AsyncEvent({ onStart: () => { console.log('执行前函数') },

  onEnd: () => {
      console.log(('执行完函数'))
  },

  onErr: () => {
      console.log('上一个函数未运行完,已被拦截')
  }

}, 10000)

const fun = function (done) { console.log('运行主体') // 模拟ajax执行延时 setTimeout(() => { console.log('模拟ajax') done() }, 2000) }

asyncEvent.run(fun) // 正常运行 asyncEvent.run(fun) // 被拦截

setTimeout(() => { asyncEvent.run((done) => { console.log('第二允许成功') done() }) }, 5000) // 正常应允许成功

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago