Skip to content

Instantly share code, notes, and snippets.

@danwrong danwrong/flight data
Created Jul 31, 2013

What would you like to do?
Just a really rough sketch of what I'd like to see as a data binding layer for flight. The idea is that its all just components and events but the model like behavior, the data binding and the rendering are all just added via mixins....
// Model
var Todo = defineComponent(asModel, function() {
// this would just be a normal component with extra methods
// that define bindable attributes and other logic{
text: String,
complete: Boolean
this.after('initialize', function() {
// listen to other events do any app specific initialization
// UI Component
var TodoItem = defineComponent(function() {
// addtl logic here
}, withTemplate('todo.mustache'), withDataBinding);
// Then attach the components
Todo.attachTo(document, { url: '/todo.json' });
TodoList.attachTo( 'div.todos', { collection: Todo });
// Under the hood the model mixin are basically just firing predictably named events on property changes,
// something like 'todo.changed.text' and the data binding mixin is handling these automatically and then
// working out when to call the render method which would be part of the withTemplate mixin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.