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

    eventualize

A JavaScript microlibrary for automatic event binding


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
9.59 kB
Created
Weekly downloads
 

Readme

Source

Eventualize Build Status

Eventualizes your code until it experiences the ultimate eventualization

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

This works in the browser, for example for jQuery elements, or more complex UI elements that fire jQuery events:

class ConfirmDialog extends Eventualize

  constructor: ->

    # 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.
    #
    # 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()


  # Called when the yes_button is clicked.
  @on_yes_button_click: ->


  # Called when the no_button is clicked.
  @on_no_button_click: ->


  # Called when the no_button is hovered.
  @on_no_button_hover: ->

It also works on the server if you are running Node.js:

class Mailer extends Eventualize

  constructor: ->

    # 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()


  # Called when the SMTP gateway fires the 'ready' event.
  @on_smtp_gateway_ready = (err, handle) ->


  # Called when the SMTP gateway fires the 'error' event.
  @on_smtp_gateway_error = (err, message) ->

Development

  • make a feature request: open an issue on the Github page
  • praise or feedback: https://github.com/kevgo
  • set up dev environment: npm install
  • run tests: npm test
  • compile a new release: grunt release
  • contribute some changes: unit-tested pull requests please! :)

FAQs

Last updated on 15 Feb 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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