Skip to content

Commit

Permalink
Merge branch 'master' of github.com:efeminella/backbone-eventbroker
Browse files Browse the repository at this point in the history
  • Loading branch information
efeminella committed Dec 2, 2012
2 parents fe7a3d0 + c1c498a commit 31fc0c7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
19 changes: 19 additions & 0 deletions LICENSE
@@ -0,0 +1,19 @@
Copyright (c) 2011 - 2012 Eric Feminella, http://www.ericfeminella.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
30 changes: 16 additions & 14 deletions README.md
@@ -1,5 +1,7 @@
## EventBroker API
Provides a general purpose [Backbone](http://documentcloud.github.com/backbone/ "Title") Event Broker implementation based on the Backbone [Events API](http://documentcloud.github.com/backbone/#Events "Title"). The `EventBroker` can be used directly to serve as a centralized event management mechanism for an entire application. Additional namespaced brokers can also be created in order to provide context specific brokers within a particular part of an application.
Provides a general purpose [Backbone](http://documentcloud.github.com/backbone/ "Title") Event Broker implementation based on the Backbone [Events API](http://documentcloud.github.com/backbone/#Events "Title").

The `EventBroker` can be used directly to serve as a centralized event management mechanism for an entire application. Namespaced brokers can also be created in order to provide context specific brokers within an application.

### Basic Usage
The `EventBroker` can be used directly to publish and subscribe to events of interest:
Expand Down Expand Up @@ -159,7 +161,7 @@ var CartView = Backbone.View.extend({
itemsBroker: Backbone.EventBroker.get('items'),

// Reference the 'inventory' EventBroker...
inventoryBroker: Backbone.EventBroker.get('inventory'),
inventoryBroker: Backbone.EventBroker.get('inventory'),

initialize: function() {
// register events/callbacks with 'items' EventBroker...
Expand Down Expand Up @@ -190,9 +192,9 @@ To test if an `EventBroker` has been created for a given `namespace`, invoke the
``` javascript
// determines if an event broker for the given namespace exists
var EventBroker = Backbone.EventBroker;
EventBroker.get( 'roles' ); // returns the 'roles' EventBroker
EventBroker.has( 'roles' ); //true
EventBroker.has( 'users' ); //false
EventBroker.get('roles'); // returns the 'roles' EventBroker
EventBroker.has('roles'); //true
EventBroker.has('users'); //false
```
Expand All @@ -202,9 +204,9 @@ To destroy an existing `EventBroker` for a given `namespace`, invoke the `destro
``` javascript
// deletes the event broker for the given namespace
var EventBroker = Backbone.EventBroker;
EventBroker.get( 'permissions' );
EventBroker.destroy( 'permissions' ); // returns the 'permissions' EventBroker
EventBroker.has( 'permissions' ); //false
EventBroker.get('permissions');
EventBroker.destroy('permissions'); // returns the 'permissions' EventBroker
EventBroker.has('permissions'); //false
```
Expand All @@ -214,12 +216,12 @@ To destroy all existing `EventBrokers`, invoke the `destroy` method with no argu
``` javascript
// deletes the event broker for the given namespace
var EventBroker = Backbone.EventBroker;
EventBroker.get( 'permissions' );
EventBroker.get( 'users' );
EventBroker.get( 'roles' );
EventBroker.get('permissions'); // returns the 'permissions' EventBroker
EventBroker.get('users'); // returns the 'users' EventBroker
EventBroker.get('roles'); // returns the 'roles' EventBroker
EventBroker.destroy();

EventBroker.has( 'permissions' ); //false
EventBroker.has( 'users' ); //false
EventBroker.has( 'roles' ); //false
EventBroker.has('permissions' ); //false
EventBroker.has('users'); //false
EventBroker.has('roles'); //false
```

0 comments on commit 31fc0c7

Please sign in to comment.