eventualize
v0.2.0
Published
A JavaScript microlibrary for automatic event binding
Downloads
1
Readme
Eventualize
convention-based automatic event binding for EventEmitters in your object-oriented JavaScript code
class Stream
constructor: ->
@socket = new Socket()
# 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
@onSocketOpen = (err, handle) -> ...
@onSocketData = (err, data) -> ...
@onSocketError = (err, message) -> ...
This also works for jQuery event emitters in the browser:
class ConfirmDialog
constructor: ->
@confirmButton = $('#confirm')
@cancelButton = $('#cancel')
# This call is equivalent to
# @confirmButton.on 'click', @onConfirmButtonClick
# @cancelButton.on 'click', @onCancelButtonClick
# @cancelButton.on 'hover', @onCancelButtonHover
eventualize this
@onConfirmButtonClick: -> ...
@onCancelButtonClick: -> ...
@onCancelButtonHover: -> ...
Development
See the developer guidelines