Socket
Socket
Sign inDemoInstall

eventualize

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.3 to 0.0.4

4

lib/eventualize.min.js

@@ -1,2 +0,2 @@

/*! eventualize 0.0.2, Copyright 2014 Kevin Goslar, see https://github.com/kevgo/eventualize */
(function(){var a;a=function(){function a(){}return a.prototype.eventualize=function(){var b,c,d,e,f,g,h,i,j;for(j=this.categorize_members(),e=j[0],c=j[1],f=0,h=e.length;h>f;f++)for(d=e[f],g=0,i=c.length;i>g;g++)b=c[g],a.is_callback_for(b,d)&&this[d].on(a.callback_event_name(b,d),this[b]);return void 0},a.prototype.categorize_members=function(){var b,c,d;d=[],b=[];for(c in this)switch(typeof this[c]){case"object":d.push(c);break;case"function":a.is_callback_method(c)&&b.push(c)}return[d,b]},a.is_callback_method=function(a){return this.string_starts_with(a,"on_")},a.is_callback_for=function(a,b){return this.string_starts_with(a,"on_"+b+"_")},a.callback_event_name=function(a,b){return a.substring(b.length+4)},a.string_starts_with=function(a,b){return a.substring(0,b.length)===b},a}(),"undefined"!=typeof module&&null!==module&&(module.exports=a),"undefined"!=typeof window&&null!==window&&(window.Eventualize=a)}).call(this);
/*! eventualize 0.0.3, Copyright 2014 Kevin Goslar, see https://github.com/kevgo/eventualize */
(function(){var a;a=function(b){var c,d,e,f,g,h,i,j,k;for(k=a.categorize_members(b),f=k[0],d=k[1],g=0,i=f.length;i>g;g++)for(e=f[g],h=0,j=d.length;j>h;h++)c=d[h],a.is_callback_for(c,e)&&b[e].on(a.callback_event_name(c,e),b[c]);return void 0},a.categorize_members=function(b){var c,d,e;e=[],c=[];for(d in b)switch(typeof b[d]){case"object":e.push(d);break;case"function":a.is_callback_method(d)&&c.push(d)}return[e,c]},a.is_callback_method=function(b){return a.string_starts_with(b,"on_")},a.is_callback_for=function(b,c){return a.string_starts_with(b,"on_"+c+"_")},a.callback_event_name=function(a,b){return a.substring(b.length+4)},a.string_starts_with=function(a,b){return a.substring(0,b.length)===b},"undefined"!=typeof module&&null!==module&&(module.exports=a),"undefined"!=typeof window&&null!==window&&(window.eventualize=a)}).call(this);
{
"name": "eventualize",
"version": "0.0.3",
"version": "0.0.4",
"description": "A JavaScript microlibrary for automatic event binding",

@@ -5,0 +5,0 @@ "devDependencies": {

# Eventualize [![Build Status](https://travis-ci.org/kevgo/eventualize.png?branch=master)](https://travis-ci.org/kevgo/eventualize)
_Eventualizes your code until it experiences the ultimate eventualization_
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.
Eventualize is a JavaScript microlibrary that introduces a
convention-over-configuration pattern so that jQuery-compatible events
are automatically bound to properly named event handlers
in your JavaScript code.
This means it makes the right "on" calls on your class members to subscribe
the matching event handlers for you automatically.
All you have to do is
* let your class inherit from Eventualize
* name your event handlers appropriately
* tell your class to eventualize itself
* name your event handlers appropriately: `on_[event source]_[event_name]`
* eventualize your class: `eventualize(this)`
This works in the browser, for example for jQuery elements, or more complex
UI elements that fire jQuery events:
This works everywhere where you handle events using JavaScript.
Here is an example for handling jQuery events in the browser:
```coffeescript
class ConfirmDialog extends Eventualize
class ConfirmDialog
constructor: ->
@confirm_button = $('#confirm')
@cancel_button = $('#cancel')
# An example button class that fires "click" events.
@yes_button = $('#yes')
# Another example button class that fires "click" and "hover" events.
@no_button = $('#no')
# Wire up all event listeners in this class.
#
# Wire up all event listeners that exist in this class.
# This is equivalent to
# - @yes_button.on 'click', @on_yes_button_click
# - @no_button.on 'click', @on_no_button_click
# - @no_button.on 'hover', @on_no_button_hover
@eventualize()
# - @confirm_button.on 'click', @on_confirm_button_click
# - @cancel_button.on 'click', @on_cancel_button_click
# - @cancel_button.on 'hover', @on_cancel_button_hover
eventualize this
# Called when the yes_button is clicked.
@on_yes_button_click: ->
console.log 'The yes button was clicked'
# Called when the no_button is clicked.
@on_no_button_click: ->
console.log 'The no button was clicked'
# Called when the no_button is hovered.
@on_no_button_hover: ->
console.log 'The no button was hovered'
```
It also works on the server if you are running Node.js:
Eventualize also works on the server, for example with Node.js:
```coffeescript
class Mailer extends Eventualize
class Stream
constructor: ->
@socket = new Socket()
# A JavaScript object that can fire 'ready' and 'error' events.
@smtp_gateway = new SmtpGateway()
# Wire up all event listeners in this class.
#
# This is equivalent to
# - @smtp_gateway.on 'ready', @on_smtp_gateway_ready
# - @smtp_gateway.on 'error', @on_smtp_gateway_error
@eventualize()
# - @socket.on 'open', @on_socket_open
# - @socket.on 'data', @on_socket_data
# - @socket.on 'error', @on_socket_error
# - @socket.on 'close', @on_socket_close
eventualize this
# Called when the SMTP gateway fires the 'ready' event.
@on_smtp_gateway_ready = (err, handle) ->
@on_socket_open = (err, handle) ->
console.log 'The socket is open'
@on_socket_data = (err, data) ->
console.log 'Received new data'
# Called when the SMTP gateway fires the 'error' event.
@on_smtp_gateway_error = (err, message) ->
@on_socket_error = (err, message) ->
console.log "Error: #{message}"
@on_socket_close = (err) ->
console.log 'Socket closed'
```

@@ -81,8 +74,8 @@

* make a feature request: open an issue on the Github page
* tell us about an idea for a new feature: https://github.com/kevgo/eventualize/issues
* praise or feedback: https://github.com/kevgo
* set up dev environment: `npm install`
* 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! :)
* contribute some changes: unit-tested pull requests please! :heart_eyes_cat:

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc