Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gevent

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gevent

simple event bus for webapp

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-44.44%
Maintainers
1
Weekly downloads
 
Created
Source

A simple eventbus for webapp.

usage:

CMD:

// module A
var ge = require('gevent');
var uid1 = ge.on('dataChange', item => drawData(item));
var uid2 = ge.on('dataChange', item => drawData2(item));

// remove all by event type
ge.off('dataChange');
// or remove one by event id if you have duplicate event name registered
ge.offOne(uid1);

// module B
var ge = require('gevent');
doAsyncRequest().then(res => ge.emit('dataChange', res));

Js Lib:

<script src='./gevent/index.js'></script>
<script>
    // listen
    gEvent.on('dataChange', item => drawData(item));
    // fire
    doAsyncRequest().then(res => gEvent.emit('dataChange', res));
</script>

apis:

  • on(eventName, callback) subscribe event

  • off(eventName) unsubscribe all event by event name

  • offOne(eventId) unsubscribe one event by event id

  • emit(eventName, params) trigger event with transition data

  • clear() clear all events subscribed

Keywords

FAQs

Package last updated on 29 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

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