News for hackers. Stuff that matters.
Re:Andro.js by brunoc on Tuesday February 21, 2012 @09:30AM (#3616532)
Strings can work fine for event names, I think op is overstating the string hell factor. But say you wanted to eliminate them you could do something like:

  var firstTouchBehaviour = {
    touchCount: 0,
    events: {
      firstTouch: 'FirstTouch'
    }, 
    setup: function(owner) {
      andro.eventer(owner).bind(this, "touch", function(contact) {
        if(contact === "added") {
          if(this.touchCount === 0) {
            andro.eventer(owner).emit(this.events.firstTouch);
          }
          this.touchCount++;
        } else if(contact === "removed") {
          this.touchCount--;
        }
      });
    }
  };
and

  var soundBehaviour = {
    setup: function(owner) {
      andro.eventer(owner).bind(this, firstTouchBehaviour.events.firstTouch , function() {
        console.log("Rarrrrrwwwwwwwwwwwwwwww");
      });
    }
  };
Re:Andro.js by maryrosecook on Tuesday February 21, 2012 @09:35AM (#3616553)
Yes, I agree.