You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

basic-events

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basic-events

a very basic event emitter

1.1.0
latest
Source
npmnpm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

basic-events

A very basic event emitter with three methods: .on, .once and .emit.

usage

import events from 'basic-events'

const app = {}
events(app)
// or
const app = events()

.on()

const unsubscribe = app.on(`data`, console.log)
app.emit(`data`, `poof`)
// `poof`
unsubscribe()
app.emit(`data`, `wroom`)
// nothing

.once()

const unsubscribe = app.once(`start`, console.log)
app.emit(`start`, `running`)
// `running`
app.emit(`start`, `jumping`)
// nothing

Keywords

event

FAQs

Package last updated on 20 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts