eventualize
Advanced tools
Comparing version 0.0.5 to 0.1.0
{ | ||
"name": "eventualize", | ||
"version": "0.0.5", | ||
"version": "0.1.0", | ||
"author": "Kevin Goslar", | ||
"description": "A JavaScript microlibrary for automatic event binding", | ||
"devDependencies": { | ||
"coffee-script": "latest", | ||
"gulp": "latest", | ||
"gulp-util": "latest", | ||
"gulp-coffee": "latest", | ||
"gulp-coffeelint": "latest", | ||
"gulp-concat": "latest", | ||
"gulp-header": "latest", | ||
"gulp-uglify": "latest", | ||
"mycha": "latest" | ||
"chai": "^3.4.1", | ||
"david": "^7.0.0", | ||
"livescript": "^1.4.0", | ||
"mocha": "^2.3.4", | ||
"sinon": "^1.17.2", | ||
"sinon-chai": "^2.8.0" | ||
}, | ||
"main": "lib/eventualize.min.js", | ||
"scripts": { | ||
"test": "mycha run --reporter spec" | ||
}, | ||
"homepage": "https://github.com/kevgo/eventualize", | ||
"license": "MIT", | ||
"main": "lib/eventualize.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:kevgo/eventualize.git" | ||
"url": "git@github.com:Originate/eventualize.git" | ||
}, | ||
"author": "Kevin Goslar", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/kevgo/eventualize/issues" | ||
"scripts": { | ||
"postpublish": "git push && git push --tags", | ||
"prepublish": "bin/build", | ||
"preversion": "npm test && npm run update", | ||
"test": "bin/spec", | ||
"update": "david update" | ||
}, | ||
"homepage": "https://github.com/kevgo/eventualize" | ||
"dependencies": { | ||
"decamelize": "^1.1.2", | ||
"uppercamelcase": "^1.1.0" | ||
} | ||
} |
@@ -1,69 +0,46 @@ | ||
# Eventualize [![Build Status](https://travis-ci.org/kevgo/eventualize.png?branch=master)](https://travis-ci.org/kevgo/eventualize) | ||
# Eventualize | ||
Eventualize introduces a | ||
convention-over-configuration mechanism for semi-automatically binding | ||
properly named event handlers | ||
to jQuery-compatible event sources | ||
in your object-oriented JavaScript code. | ||
> convention-based automatic event binding | ||
for [EventEmitters](https://nodejs.org/api/events.html) | ||
in your object-oriented JavaScript code | ||
All you have to do is | ||
* name your event handlers appropriately: `on_[event source]_[event_name]` | ||
* eventualize your class: `eventualize(this)` | ||
[![Circle CI](https://circleci.com/gh/Originate/eventualize.svg?style=shield)](https://circleci.com/gh/Originate/eventualize) [![Dependency Status](https://david-dm.org/Originate/eventualize.svg)](https://david-dm.org/Originate/eventualize) [![devDependency Status](https://david-dm.org/Originate/eventualize/dev-status.svg)](https://david-dm.org/Originate/eventualize#info=devDependencies) | ||
This works everywhere where you handle events using JavaScript. | ||
Here is an example for handling jQuery events in the browser: | ||
```coffeescript | ||
class ConfirmDialog | ||
class Stream | ||
constructor: -> | ||
@confirm_button = $('#confirm') | ||
@cancel_button = $('#cancel') | ||
@socket = new Socket() | ||
# Wire up all event listeners that exist in this class. | ||
# This is equivalent to | ||
# - @confirm_button.on 'click', @on_confirm_button_click | ||
# - @cancel_button.on 'click', @on_cancel_button_click | ||
# - @cancel_button.on 'hover', @on_cancel_button_hover | ||
# This call wires up all properly named event listeners in this class. | ||
# It is equivalent to running: | ||
# @socket.on 'open', @onSocketOpen | ||
# @socket.on 'data', @onSocketData | ||
# @socket.on 'error', @onSocketError | ||
eventualize this | ||
@on_yes_button_click: -> | ||
console.log 'The yes button was clicked' | ||
@on_no_button_click: -> | ||
console.log 'The no button was clicked' | ||
@on_no_button_hover: -> | ||
console.log 'The no button was hovered' | ||
@onSocketOpen = (err, handle) -> ... | ||
@onSocketData = (err, data) -> ... | ||
@onSocketError = (err, message) -> ... | ||
``` | ||
Eventualize also works on the server, for example with Node.js: | ||
This also works for jQuery event emitters in the browser: | ||
```coffeescript | ||
class Stream | ||
class ConfirmDialog | ||
constructor: -> | ||
@socket = new Socket() | ||
@confirmButton = $('#confirm') | ||
@cancelButton = $('#cancel') | ||
# Wire up all event listeners in this class. | ||
# This is equivalent to | ||
# - @socket.on 'open', @on_socket_open | ||
# - @socket.on 'data', @on_socket_data | ||
# - @socket.on 'error', @on_socket_error | ||
# - @socket.on 'close', @on_socket_close | ||
# This call is equivalent to | ||
# @confirmButton.on 'click', @onConfirmButtonClick | ||
# @cancelButton.on 'click', @onCancelButtonClick | ||
# @cancelButton.on 'hover', @onCancelButtonHover | ||
eventualize this | ||
@on_socket_open = (err, handle) -> | ||
console.log 'The socket is open' | ||
@on_socket_data = (err, data) -> | ||
console.log 'Received new data' | ||
@on_socket_error = (err, message) -> | ||
console.log "Error: #{message}" | ||
@on_socket_close = (err) -> | ||
console.log 'Socket closed' | ||
@onConfirmButtonClick: -> ... | ||
@onCancelButtonClick: -> ... | ||
@onCancelButtonHover: -> ... | ||
``` | ||
@@ -74,8 +51,2 @@ | ||
* tell us about an idea for a new feature: https://github.com/kevgo/eventualize/issues | ||
* praise or feedback: https://github.com/kevgo | ||
* set up the development environment on your machine: `npm install` | ||
* run tests: `npm test` | ||
* compile a new release: `grunt release` | ||
* contribute some changes: unit-tested pull requests please! :heart_eyes_cat: | ||
See the [developer guidelines](CONTRIBUTING.md) |
Sorry, the diff of this file is not supported yet
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
6
51
0
4182
2
5
52
+ Addeddecamelize@^1.1.2
+ Addeduppercamelcase@^1.1.0
+ Addedcamelcase@1.2.1(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addeduppercamelcase@1.1.0(transitive)