Skip to content

Instantly share code, notes, and snippets.

@hughfdjackson
Created June 22, 2012 00:27
Show Gist options
  • Select an option

  • Save hughfdjackson/2969479 to your computer and use it in GitHub Desktop.

Select an option

Save hughfdjackson/2969479 to your computer and use it in GitHub Desktop.
LucidJS example
/*
LucidJS is a lib with a .emitter constructor function (one that doesn't require the new keyword; what i
tend to call informal constructor functions). It provides an object with the normal pub/sub methods; .on,
.off and .trigger
*/
var player = _.extend({
x: 0
, y: 0
, move: function(x, y){
this.x += x
this.y += y
this.trigger('change', 'has moved')
}
, LucidJS.emitter())
player.on('change', function(msg){ console.log(msg) })
player.move(1, 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment