Created
July 31, 2013 17:39
-
-
Save danwrong/6124263 to your computer and use it in GitHub Desktop.
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....
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
// Model | |
var Todo = defineComponent(asModel, function() { | |
// this would just be a normal component with extra methods | |
// that define bindable attributes and other logic | |
this.properties({ | |
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