🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

emy

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

emy

An adorably small event emitter/pubsub library.

1.1.0
latest
Source
npm
Version published
Weekly downloads
3
200%
Maintainers
1
Weekly downloads
 
Created
Source

emy

An adorably small event emitter/pubsub library.

Usage

import emy from 'emy';

const [publish, subscribe] = emy();

const unsubscribe = subscribe((event) => {
  console.log(`Hello ${event.value}!`);
});

publish({ value: 'world' });

unsubscribe();

API

emy()

Creates a new event emitter.

const [publish, subscribe] = emy();

Return value

An array containing 2 functions, publish and subscribe.

These can be renamed to whatever you prefer, for example [emit, on] or [publishFoo, subscribeFoo].

publish(event)

Invokes all subscribed listeners.

publish({ value: 'world' });

Parameters

  • event any value to be passed to each listener.

subscribe(listener)

Register a listener.

const unsubscribe = subscribe((event) => {
  console.log(`Hello ${event.value}!`);
});

unsubscribe();

Parameters

  • listener function to call when event is published.

Return value

Returns a function which unregisters the listener when called.

Keywords

event

FAQs

Package last updated on 16 Apr 2021

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