Skip to content

Commit

Permalink
Adds documentation for object syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesplease committed Jul 19, 2014
1 parent 75a1daf commit 425a1b6
Showing 1 changed file with 38 additions and 24 deletions.
62 changes: 38 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,37 @@ myChannel.comply('default', function(commandName) {
myChannel.command('someUnhandledCommand');
```

To register multiple requests at once you may also pass a hash of requests.

```js
// Create a hash of commands
var commandsHash = {
'some:command': myCallback,
'some:other:command': someOtherCallback
};

// Connect all of the events at once
myChannel.comply(commandsHash);
```

Returns the instance of Commands.

##### `complyOnce( commandName, callback [, context] )`

Register a handler for `commandName` that only executes a single time.

Like `comply`, you may also pass a hash of commands to register many at once. Refer to the `comply` documentation above
for an example.

Returns the instance of Commands.

##### `stopComplying( [commandName] )`

If `commandName` is passed then that handler is removed from the object. Otherwise, all handlers are removed.

Like `comply`, you may also pass a hash of commands to remove many at once. Refer to the `comply` documentation above
for an example.

Returns the instance of Commands.

### Requests
Expand All @@ -252,18 +271,37 @@ myChannel.reply('default', function(requestName) {
myChannel.request('someUnhandledRequest');
```

To register multiple requests at once you may also pass a hash of requests.

```js
// Create a hash of requests
var requestsHash = {
'some:request': myCallback,
'some:other:request': someOtherCallback
};

// Connect all of the replies at once
myChannel.reply(requestsHash);
```

Returns the instance of Requests.

##### `replyOnce( requestName, callback [, context] )`

Register a handler for `requestName` that will only be called a single time.

Like `reply`, you may also pass a hash of replies to register many at once. Refer to the `reply` documentation above
for an example.

Returns the instance of Requests.

##### `stopReplying( [requestName] )`

If `requestName` is passed then this method will remove that reply. Otherwise, all replies are removed from the object.

Like `reply`, you may also pass a hash of replies to remove many replies. Refer to the `reply` documentation above
for an example.

Returns the instance of Requests.

### Channel
Expand All @@ -276,30 +314,6 @@ The name of the channel.

Destroy all handlers from Backbone.Events, Radio.Commands, and Radio.Requests from the channel. Returns the channel.

##### `connectEvents( eventsHash )`

A convenience method for connecting a hash of events to the channel. Returns the
channel.

```js
// Set up a hash of events
var eventsHash = {
'some:event': myCallback,
'some:other:event': someOtherCallback
};

// Connect all of the events at once
myChannel.connectEvents(eventsHash);
```

##### `connectCommands( commandsHash )`

A convenience method for connecting a hash of Commands handles to the channel. Returns the channel.

##### `connectRequests( requestsHash )`

A convenience method for connecting a hash of Requests replies to the channel. Returns the channel.

### Radio

##### `channel( channelName )`
Expand Down

0 comments on commit 425a1b6

Please sign in to comment.