0.1.0 • Published 4 years ago

eventemitter-ice v0.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

EventEmitter

Simple encapsulation of event subscription and publication

Installation

npm install eventemitter-ice

# or

yarn add eventemitter-ice

Usage

CDN

<script src="./dist/event-emitter.js"></script>

Module

import EventEmitter from 'eventemitter-ice'

const eventEmitter = new EventEmitter()

Example

import EventEmitter from 'eventemitter-ice'

const emitter = new EventEmitter()
emitter.on('close', function (data) {
  alert('close: ' + data)
})
emitter.once('open', function (data) {
  alert('open: ' + data)
})
emitter.emit('open', 'open the window')

API

Options

paramdescriptiontypedefault value
----

Methods

namedescriptionparam
onMessage event binding functioneventsName: string, callback: function
onceMessage event binding function, which is fired only once by the bound functioneventsName: string, callback: function
offCancel message eventid: number
emitTrigger messageeventsName: string, data: any

License

Copyright (c) 202O ytICE. (MIT License)