5.0.0 • Published 7 months ago

eventmonger v5.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
7 months ago

EventMonger is a dead simple event system.

I didnt like a lot of the syntax for classical event system, so presto.

var { Event, emit, on, off, once, when, clear } = require('eventmonger')
// or
import { Event, emit, on, off, once, when, clear } from 'eventmonger'

let sampleEvent = Event()

let callback = name => console.log("hello ", name, "!")

// register a callback on an event
// note: returns the callback
on(sampleEvent, callback)

// remove a callback from an event
// note: returns the callback
off(sampleEvent, callback)

// once will return a promise that will resolve once the event if fired
once(sampleEvent).then(data => console.log(data))

// fire off the event!
// note: events can only have one paramter
emit(sampleEvent, "world")

// you can use 'when' to filter a callback!
on(sampleEvent, when(name => name == "world", name => console.log("hello world")))

// you can use clear, to well, clear all the callbacks from an Event
// note: returns the event
clear(sampleEvent)
5.0.0

7 months ago

4.1.0

4 years ago

4.0.0

4 years ago

3.2.2

4 years ago

3.3.2

4 years ago

3.2.1

4 years ago

3.2.0

4 years ago

3.1.0

4 years ago

3.0.0

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago