isg-events@0.1.0
Synchronous and asynchronous cross-platform library for organizing events.
Install
- NPM
npm install isg-events
- GIT
git clone https://github.com/isglazunov/isg-events.git
- download from releases
Require
Depends on the modules:
Indirect dependency
The module can be connected using all supported module isg-connector@0.0.2 methods.
window (Browser)
define (AMD/Requirejs)
;
require (Node.js)
var isgEvents = ;var Events = isgEventsEvents;
Usage
Available variables
isgEvents.version
Contains the current version of the module.
isgEvents.dependencies
Contains links to the required modules.
new Events;
var events = ;
or
var {};MyEventsprototype = ;
events.on(name, callback[, options]);
Available options:
sync: false // true // asynchronous / synchronous call handler. context: this // this in the handler for the default `container` self: false // true // adds the first argument of `self` limit: null // Number // how many times to call the handler
Asynchronous event
The following will be called only after a call next
.
container;
Synchronous event.
The function next
will be called automatically after the call handler.
container;
Access to the handler.
The handler described below exclude yourself from the list of event handlers immediately after the call.
container;
Available attributes of self variable:
index: Number // Personal index of each handler off: Function // Short-cut method to the handler could disable itself limit: Function // Returns a copy of the options limit // If the first argument is a number or null, the option replaces the limit for him
events.once(name, callback[, options]);
Equivalent to calling: events.on(name, callback, {limit: 1});
events.trigger(name[[, Array arguments], callback]);
container;
If you call the trigger
after the announcement of the above handlers, the console will look like this:
02trigger1
events.off(query);
Available query attributes:
name: undefined // String callback: undefined // Function sync: undefined // Boolean context: undefined // any self: undefined // Boolean limit: undefined // Number or Null
Each specified attribute narrows the scope of the search to detach from the list of handlers.
container;
Disable all event handlers "action"
Versions
0.1.0
To connect the module used isg-connector@0.0.2.
0.0.12
New requiring method for Node.js.
New configuration prefix. _events to _isgEvents.
Some fixes and cleaning.
0.0.11
New requiring methods. Some fixes.
0.0.10
Bigger readme. Some fixes.
0.0.9
The basic functionality.