Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Data Bind Everything

Stuart Lodge
December 04, 2013

Data Bind Everything

Talk given at NDC London December 4th 2013

Stuart Lodge

December 04, 2013
Tweet

More Decks by Stuart Lodge

Other Decks in Technology

Transcript

  1. @slodge MvvmCross • C# • Microsoft, Xamarin and beyond! •

    PCL • IoC • Convention-Based Mvvm • Data-Binding
  2. @slodge MvvmCross • C# • Microsoft, Xamarin and beyond! •

    PCL • IoC • Convention-Based Mvvm • Data-Binding
  3. @slodge • Building a Data-Binding Engine • MvvmCross v1/v2 Data-Binding

    • MvvmCross v3 - Rio and Tibet • The Dark Side?
  4. @slodge • Building a Data-Binding Engine • MvvmCross v1/v2 Data-Binding

    • MvvmCross v3 - Rio and Tibet • The Dark Side?
  5. @slodge … in Android and iOS UIKit? ViewModel INotifyPropertyChanged Control

    TextProperty DependencyProperty DependencyObject Values BindingOperations FirstName C# Property PropertyChanged C# Event
  6. @slodge … in Android and iOS UIKit? ViewModel INotifyPropertyChanged Control

    TextProperty DependencyProperty DependencyObject Values BindingOperations FirstName C# Property PropertyChanged C# Event Text TextChanged OurBindingEngine
  7. @slodge What’s a Binding Engine do 1. Initially copy values

    ViewModel -> View 2. When ViewModel changes, update View 3. When View changes, update ViewModel 4. Don’t loop! 5. When the View disappears, dispose the bindings
  8. @slodge • Building a Data-Binding Engine • MvvmCross v1/v2 Data-Binding

    • MvvmCross v3 - Rio and Tibet • The Dark Side?
  9. @slodge … in Android and iOS UIKit? ViewModel INotifyPropertyChanged Control

    TextProperty DependencyProperty DependencyObject Values BindingOperations FirstName C# Property PropertyChanged C# Event Text TextChanged MvxBindingEngine
  10. @slodge Syntax - Fluent set.Bind(label) .For(t => t.Text) .To(vm =>

    vm.Customer.Gender) .WithConversion(“FormalGreeting”) .WithFallback(“Mr”)
  11. @slodge Binding Parts • Path • Mode • Converter •

    ConverterParameter • FallbackValue
  12. @slodge Path • Simple FirstName • Chained Customer.FirstName • Indexed

    Customers[0].FirstName Customers[“Fred”].FirstName • Whole Object .
  13. @slodge Mode • One Way • Two Way • One

    Way To Source • One Time • … and Default
  14. @slodge Binding Targets • It just works TM • When

    it doesn’t just work: – Inheritance – Intermediate – Custom Bindings
  15. @slodge • Building a Data-Binding Engine • MvvmCross v1/v2 Data-Binding

    • MvvmCross v3 - Rio and Tibet • The Dark Side?
  16. @slodge Tibet Binding extensions • MultiBinding • Literals • +

    - concatenation • Function-like ValueConversion • Recursive evaluation • ValueCombiners (MultiValueConverters) • If, Format, &&, ||, <, >, ==, …
  17. @slodge Rio Extensions • Fody integration • Field Binding •

    Method Bindings • Extensible – interfaces and plugins
  18. @slodge • Building a Data-Binding Engine • MvvmCross v1/v2 Data-Binding

    • MvvmCross v3 - Rio and Tibet • The Dark Side?
  19. @slodge "We should forget about small efficiencies, say about 97%

    of the time: premature optimization is the root of all evil" Performance
  20. @slodge Performance Analysis Simple UI test: – ViewModel: 10000 *

    “Value = Value+1” – View: TextView bound “Text Value”
  21. @slodge • Building a Data-Binding Engine • MvvmCross v1/v2 Data-Binding

    • MvvmCross v3 - Rio and Tibet • The Dark Side?