【文件属性】:
文件名称:next-event:下次发出特定事件时调用函数
文件大小:3KB
文件格式:ZIP
更新时间:2021-04-28 22:22:05
JavaScript
下一事件
下次发出特定事件时调用函数
npm install next-event
基本上就像.once一样,但是速度更快,因为它不会在每个事件上都进行gc事件处理程序。
用法
var nextEvent = require ( 'next-event' )
var ontest = nextEvent ( emitter , 'test' )
ontest ( function ( ) {
console . log ( 'i am only called once' )
} )
emitter . emit ( 'test' )
emitter . emit ( 'test' )
请注意,在发出下一个事件时,只会调用上例中传递给ontest的最后一个函数
ontest ( function ( ) {
console . log ( 'i am never called'
【文件预览】:
next-event-master
----.gitignore(13B)
----package.json(599B)
----.travis.yml(51B)
----LICENSE(1KB)
----index.js(244B)
----test.js(992B)
----README.md(1000B)