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
Created
Weekly downloads
 

Readme

Source

Eventualize Build Status

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.

All you have to do is

  • name your event handlers appropriately: on_[event source]_[event_name]
  • eventualize your class: eventualize(this)

This works everywhere where you handle events using JavaScript. Here is an example for handling jQuery events in the browser:

class ConfirmDialog

  constructor: ->
    @confirm_button = $('#confirm')
    @cancel_button = $('#cancel')

    # 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
    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'

Eventualize also works on the server, for example with Node.js:

class Stream

  constructor: ->
    @socket = new Socket()

    # 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
    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'

Development

FAQs

Last updated on 25 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