Skip to content

Instantly share code, notes, and snippets.

@cam-stitt
Created August 14, 2013 04:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cam-stitt/6228030 to your computer and use it in GitHub Desktop.
Save cam-stitt/6228030 to your computer and use it in GitHub Desktop.
An example of the event flow in Flight.
define(function(require) {
var defineComponent = require('flight/lib/component');
return defineComponent(users);
var users = function() {
this.loadUsers = function(ev, data) {
var users = [{id: 1, name: 'Jack'}, {id:2, name: 'Jill'}];
this.trigger(document, 'dataUsers', {users: users});
};
this.after('initialize', function() {
this.on(document, 'uiNeedsUsers', this.loadUsers);
});
}
});
require(['data/users', 'ui/users'], function(UsersData, UsersUI) {
UsersData.attachTo(document);
UsersUI.attachTo(document);
});
define(function(require) {
var defineComponent = require('flight/lib/component');
return defineComponent(users);
var users = function() {
this.renderUsers = function(ev, data) {
// Render the users however you want
};
this.after('initialize', function() {
this.trigger(document, 'uiNeedsUsers');
this.on(document, 'dataUsers', this.RenderUsers);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment