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

node-bound

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-bound

A simple module to help streamline event binding

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Weekly downloads
 
Created
Source

Bound Build Status

a simple way do a large amount of event bindings. Heavily inspired by backbones event bindings in views. Bound2

To Install

$ component install honeinc/bound

or on node

$ npm install node-bound

Example Usage

Lets say you have a controller, that you want to consume some events from a common messaging system that uses events. Other component used in example is honeinc/emit.

var emit = require('emit'),
    bound = require('bound');

function UserController ( ) {
    bound( emit, {
        'user:save' : 'handleSave',
        'user:create' : 'handleCreate',
        'user:delete' : 'handleDelete'
    }, this );
}

UserController.prototype.handleSave = function ( ) { /* ... */ };
UserController.prototype.handleCreate = function ( ) { /* ... */ };
UserController.prototype.handleDelete = function ( ) { /* ... */ };

This will bind all the events in the given context to the right method and keep the context that is given, which is great when in the context of a constructor.

    bound( emitter, eventMethodObject, context );
// eventEmitter ^ event : method ^        ^ context of method

You can also unbind events that get bound by bound.

    bound.unbind( emitter, eventMethodObject, context );

Contributing

To contribute you will need to make sure all the test are passing. To run the test you will need mocha. Then install the dependecies.

$ npm install

Then to run the test

$ npm test

CHANGES

0.1.0

  • Add support for binding to node-style emitters in addition to browser-based emitters.

Keywords

FAQs

Package last updated on 20 Nov 2014

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