1.0.3 • Published 5 years ago

gc-event v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

gc-event

this object is a singleton that you can register events and execute in other scope

import eventInstance from 'gc-event'
// import eventInstance from 'gc-event/es5' //import as es5

eventInstance.on('multiple',function(a,b,c){
    console.log(`a + b is :${a+b}`)
})

eventInstance.on('multiple',function(a,b,c){
    console.log(`b + c is :${b+c}`)
})

eventInstance.once('once',function(){
    console.log(`register 'once' for the first time`)
})

eventInstance.once('once',function(a,b,c){
    console.log(`register 'once' for the second time`)
})

eventInstance.emit('multiple',1,2,3)
eventInstance.emit('once')
eventInstance.remove('multiple')
eventInstance.remove('once')