Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/allouis/minivents
✨JavaScript events in 355 Bytes✨
https://github.com/allouis/minivents
Last synced: 4 days ago
JSON representation
✨JavaScript events in 355 Bytes✨
- Host: GitHub
- URL: https://github.com/allouis/minivents
- Owner: allouis
- License: mit
- Created: 2013-08-27T18:02:36.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2022-03-29T10:10:04.000Z (over 2 years ago)
- Last Synced: 2024-10-13T21:35:33.417Z (23 days ago)
- Language: JavaScript
- Homepage:
- Size: 86.9 KB
- Stars: 414
- Watchers: 17
- Forks: 36
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-jsgames - minivents - Tiny eventing for javascript. (Uncategorized / Uncategorized)
README
# minivents [![Build Status](https://travis-ci.org/allouis/minivents.svg?branch=master)](https://travis-ci.org/allouis/minivents)
http://allouis.github.io/minivents/
# API
`on` : Listen to event. Params { type:`String`, callback:`Function` | context:`Object` }. Returns `target`.
`off` : Stop listening to event. Params { type:`String` | callback:`Function` }. Returns `target`.
`emit`: Emit event. Params { type:`String` | data:`Object` }. Returns `target`.
# Constructor Example
```javascript
var sandbox = new Events();
sandbox.on("event", function(){
// do stuff
});sandbox.emit("event"); //does stuff
sandbox.off("event");
sandbox.emit("event"); //does not do stuff
```
# Mixin Example
```javascript
var sandbox = {
otherStuff: true
};Events(sandbox);
sandbox.on("event", function(){
// do stuff
});sandbox.emit("event"); //does stuff
sandbox.off("event");
sandbox.emit("event"); //does not do stuff
```