Created
August 14, 2013 04:33
-
-
Save cam-stitt/6228030 to your computer and use it in GitHub Desktop.
An example of the event flow in Flight.
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
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); | |
}); | |
} | |
}); |
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
require(['data/users', 'ui/users'], function(UsersData, UsersUI) { | |
UsersData.attachTo(document); | |
UsersUI.attachTo(document); | |
}); |
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
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