honk-events
Honk! Events! ============= A super-small events package for adding basic events to instances. There's a simple mechanism to cleanup bindings for objects that are about to be destroyed (so they don't hang around un-GC-able forever). It's reccomended.
Last updated 7 years ago by mchadwick .
Original npm · Tarball · package.json
$ cnpm install honk-events 
SYNC missed versions from official npm registry.

Honk! Events!

A super-small events package for adding basic events to instances. There's a simple mechanism to cleanup bindings for objects that are about to be destroyed (so they don't hang around un-GC-able forever). It's reccomended.

Usage

mixinEvents = require 'honk-events'

class Producer
  constructor: ->
    mixinEvents(this)

  announce: (name) ->
    @trigger 'say', name

class Consumer
  constructor: (producer) ->
    mixinEvents(this)

    @on producer, 'say', (name) ->
      console.log "Producer said '#{name}!'"

  destroy: ->
    console.log 'Goodbye cruel world'


producer = new Producer()
consumer = new Consumer()

producer.say 'Hello!'
# >>> Producer said 'Hello!!'

# Clean up any events the consumer has accumulated
consumer.destroy()
# >>> Goodbye curel world

Current Tags

  • 0.0.3                                ...           latest (7 years ago)

3 Versions

  • 0.0.3                                ...           7 years ago
  • 0.0.1                                ...           7 years ago
  • 0.0.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (2)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |