Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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
  • Socket score

Version published
Weekly downloads
2
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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc