https://github.com/rumkin/occur
Alternative event lib
https://github.com/rumkin/occur
Last synced: 12 months ago
JSON representation
Alternative event lib
- Host: GitHub
- URL: https://github.com/rumkin/occur
- Owner: rumkin
- License: gpl-2.0
- Created: 2013-08-01T08:44:48.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2014-06-30T14:24:21.000Z (almost 12 years ago)
- Last Synced: 2025-06-22T18:05:55.846Z (12 months ago)
- Language: JavaScript
- Size: 164 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Occur
=====
Occur event is an implementation of w3c-like events.
Example
---
Example with inheritance.
```javascript
var Occur = require('occur');
var utils = require('utils');
function SomeHandler() {
Occur.call(this);
}
utils.inherits(SomeHandler, Occur);
var handler = new SomeHandler();
handler.on('handle', function(e) {
console.log(e.type, e.value, e.target === handler);
});
// Trigger events
handler.trigger({type : 'handle', value : 1});
// --> handle 1 true
handler.trigger('handle');
// --> handle undefined true
handler.trigger(new Occur.Event('handle', {value: 2}));
// --> handle 2 true
```