Skip to content

AkashiGakki/observer-emit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

observer-emit

👀 A Node.js event emitter works in the browser.

NPM version

Install

using npm

$ npm i observer-emit

using yarn

$ yarn add observer-emit

using pnpm

$ pnpm i observer-emit

Usage

import observer from 'observer-emit'

observer.on('asuka', () => console.log('asuka', 1))
observer.on('nagi', () => console.log('nagi'))

observer.off('asuka')
observer.on('asuka', () => console.log('asuka', 2))

observer.emit('asuka') // asuka 2
observer.emit('nagi') // nagi

observer.once('ume', () => console.log('ume'))
observer.emit('ume') // ume
observer.emit('ume')
observer.emit('ume')

License

MIT License © 2022 Akashi Sai