Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tarabyte/hybrid-events
Hybrid events for plain javascript objects.
https://github.com/tarabyte/hybrid-events
Last synced: about 2 months ago
JSON representation
Hybrid events for plain javascript objects.
- Host: GitHub
- URL: https://github.com/tarabyte/hybrid-events
- Owner: Tarabyte
- License: mit
- Created: 2014-04-13T14:41:00.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-04-16T21:22:48.000Z (over 10 years ago)
- Last Synced: 2024-04-23T23:23:31.552Z (8 months ago)
- Language: JavaScript
- Size: 172 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
hybrid-events
=============Hybrid events for plain javascript objects.
What is hybrid event?
---------------------Hybrid event is a function that acts as:
* Binder if argument is a function.
* Trigger otherwise.Event definition
----------------To define new event you need to call `HybridEvent` with an event name. For example
```javaacript
var event = HybridEvent('itHappens');
```This will define an event name `itHappens` without any additional logic.
Event parameters
----------------One can speciefy additional options for event to implement custom setup/teardown and bubbling logic.
```javascript
var verySpecialEvent = HybridEvent('specialEvent', {
setup: function(name){
//custom setup logic called when the first callback was added
},
add: function(name) {
//custom logic on every callback added
},
remove: function(name) {
//custom logic on every callback removed
},
teardown: function(name) {
//custom teardown logic called when all callbacks were removed
},
propagate: function() {
//lookup parent for current event target.
}
});
```