Skip to content

Instantly share code, notes, and snippets.

@cameronhunter
Created July 31, 2013 18: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 cameronhunter/6124794 to your computer and use it in GitHub Desktop.
Save cameronhunter/6124794 to your computer and use it in GitHub Desktop.
Some research and thoughts around data-binding for flight.
## Definition ##
"Data binding is general technique that binds two data/information sources together and maintains synchronization of data." – http://en.wikipedia.org/wiki/Data_binding
UI data binding binds UI elements to an application domain model. Most frameworks employ the Observer pattern as the underlying binding mechanism. To work efficiently, UI data binding has to address input validation and data type mapping.
A bound control is a widget whose value is tied to a field in a recordset (i.e., a column in a row of a table). Changes made to data within the control are automatically saved to the database when the control's exit event triggers.
## Execution ##
From http://www.lucaongaro.eu/blog/2012/12/02/easy-two-way-data-binding-in-javascript/
* We need a way to specify which UI elements are bound to which properties
- Most implementations use data-* attributes
* We need to monitor changes on the properties and on the UI elements
* We need to propagate any change to all bound objects and elements
## Thoughts ##
* Models are data components
- Requires get(property) and set(property, value)
- Triggers model:property:change events
* Views are UI components with templates
- Attached to the DOM
- Updated based on model:property:change events
- Can also trigger model:property:change events
* Do we need some central pubsub controller?
* Declare model name as data-model=”person”, then all events such as person:change can be caught and fed to that element. That element then can break apart the event and update the view accordingly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment