Skip to content
This repository has been archived by the owner on Feb 14, 2018. It is now read-only.
/ backbone.listener Public archive

A simple Backbone plugin to create Backbone.Event listener objects

License

Notifications You must be signed in to change notification settings

gmr/backbone.listener

Repository files navigation

Backbone.Listener

A simple plugin that adds a new object type for easily binding to events trigged on the Backbone object similar to how you can bind to DOM events with Backbone.View.

Build Status NPM version Coverage Status

Requirements

Backbone (tested with 1.1.2)

Example

var MyListener = Backbone.Listener.extend({

  events: {
    'bar': 'onBar',
    'foo': 'onFoo'
  },

  onBar: function(message) {
    console.log("onBar: " + message);
  },

  onFoo: function(message) {
    console.log("onFoo: " + message);
  }

});

var listener = new MyListener();

Backbone.trigger('foo', 'bar');
Backbone.trigger('bar', 'baz');

About

A simple Backbone plugin to create Backbone.Event listener objects

Resources

License

Stars

Watchers

Forks

Packages

No packages published