Skip to content

Pure-ish functional, immutable event-emitter library for javascript

Notifications You must be signed in to change notification settings

zchbndcc9/mimid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MimidLogo

Mimid

Functional event-emitter library for javascript. Each time you call a function on a current mimid, a new mimid is returned to the caller. This allows you to chain multiple emits and provides composability of event emitters.

  • 🐱 Functional

  • 🐜 129 Bytes GZipped

  • 🚫 No dependencies

Installation

yarn add mimid

or

npm add mimid

How-To

import mimid fromm 'mimid'

const emitter = 
  mimid()
    .on("hello", () => console.log("hello there")
    .on("goodbye", (data) => console.log(`Goodbye ${data})
    
emitter
  .emit("hello")
  .emit("goodbye", "Jim")

API

on(event, handler)

Create a new event emitter with the given event and its associated handler

close(event)

Creates a new event emitter without the event in its listeners

off()

Creates a new event emitter without any listeners

emit(event, data)

Emit an event to the subscribers to the current emitter and returns a new event emitter with the same listeners

listeners()

Retrieves an array of listeners from the current event emitter

About

Pure-ish functional, immutable event-emitter library for javascript

Resources

Stars

Watchers

Forks

Packages

No packages published