Created
September 10, 2014 07:50
-
-
Save justinvdm/804e5444845ffae10066 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Event = vumigo.events.Event; | |
var BaseApp = App.extend(function(self) { | |
App.call(self, 'states:start'); | |
self.states.add('states:start', function(name) { | |
// a bit of a yucky way of doing events, wish we opted for a more | |
// nodejs like approach (.emit('foo', {bar: 'baz'})) | |
// .emit returns a promise | |
return self | |
.emit(new Event('foo', {bar: 'baz'})) | |
.thenResolve(new EndState(name, {text: 'ham'})); | |
}); | |
}); | |
var AppA = App.extend(function(self) { | |
BaseApp.call(self); | |
// one way of listening to events | |
self.init = function() { | |
self.on('foo', function(e) { | |
// you can return a promise here | |
console.log(e); // => {bar: 'baz'} | |
}); | |
}; | |
}); | |
var AppB = App.extend(function(self) { | |
BaseApp.call(self); | |
// different way of listening to events | |
self.events = { | |
'foo': function(e) { | |
// you can return a promise here | |
console.log(e); // => {bar: 'baz'} | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment