-
Notifications
You must be signed in to change notification settings - Fork 2
PublisherChannel
| Jump To | Go Back |
Methods | Variables |
|---|
A simple publisher-subscriber framework. Methods are bound to the PublisherChannel, and called with the supplied parameters when a channel is notified they belong to. These methods are called at the scope they are bound, which means they are run as if they were a part of the subscribing instance. Thus any number of instances can subscribe to a single PublisherChannel, or even the same one multiple times if desired.
var _channel = new PublisherChannel()
_channel.add( function( _message ) {
show_debug_message( _message );
}
_channel.notify( "Hello World!" );
| Jump To | top |
add | remove | notify | size |
|---|
Returns: method
Throws: InvalidArgumentType
| Name | Type | Purpose |
|---|---|---|
| method | func | The method to add to the list. |
Adds the specified method to the list of listeners. If the provided argument was not a method, InvalidArgumentType will be thrown.
| Name | Type | Purpose |
|---|---|---|
| method | method |
The method to remove fromt he list. |
Removes the specified listener from the channel.
| Name | Type | Purpose |
|---|---|---|
| message | mixed |
The message to pass to the subscribers. |
Calls each of the subscriber methods with message as an argument.
| Name | Type | Purpose |
|---|---|---|
| None |
Returns the number of subscribers in the channel
| Jump To | top |
|---|
| Name | Type | Initial | Purpose |
|---|---|---|---|
| __Subscribers | undef |
[] | No description. |
Devon Mullane 2020