pro-event-bus-ts
v1.0.0
Published
event,event-bus,event-center
Downloads
1
Readme
pro-event-bus-ts
npm install
npm i pro-event-bus-ts
node
const ProEventBus = require('pro-event-bus-ts')
const eventBus = new ProEventBus()
eventBus.on('test', () => {
console.log('test pro-event-bus');
})
eventBus.once('once', () => {
console.log('test pro-event-bus-once');
})
eventBus.emit('test')
eventBus.emit('test')
eventBus.emit('once')
eventBus.emit('once')
eventBus.offAll()
eventBus.emit('test')
/*
test pro-event-bus
test pro-event-bus
test pro-event-bus-once
*/
web
<script src="./pro-event-bus/index.js"></script>
// https://cdn.jsdelivr.net/npm/[email protected]/index.js
<script>
const eventBus = new ProEventBus()
eventBus.on('test', () => {
console.log('test pro-event-bus');
})
eventBus.once('once', () => {
console.log('test pro-event-bus-once');
})
eventBus.emit('test')
eventBus.emit('test')
eventBus.emit('once')
eventBus.emit('once')
eventBus.offAll()
eventBus.emit('test')
/*
② test pro-event-bus
test pro-event-bus-once
*/
</script>