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

MVVM Without XAML

MVVM Without XAML

In this talk, learn how to use the Model-View-ViewModel pattern to write testable user interfaces on platforms beyond XAML-based ones. With ReactiveUI, an MVVM Framework that is designed for cross-platform applications, you can see how to write ViewModels that run on iOS, Android, and Windows, while still creating native experiences on each platform.

Specifically, we’ll dive into Cocoa / AppKit, and see how to wire up ViewModels to Cocoa Views and ViewControllers, using the same syntax as in a WPF application, providing an amazing potential for code reuse in cross-platform environments.

Check out the code for this talk at https://github.com/reactiveui/rxui_qcon

Ana Betts

March 16, 2013
Tweet

More Decks by Ana Betts

Other Decks in Programming

Transcript

  1. How to write the same code and have it run

    everywhere Alternate Title:
  2. “The user can’t click Login until the user name and

    password is filled out.” “We need to try to log in with the credentials and pop up an error if it doesn’t work.” “We need to show a ‘working’ spinner while the login information is being checked.” “Once it succeeds, we need to navigate to the opening page of the application.”
  3. MVVM In A Nutshell UI Frameworks are untestable because they’re

    written by Apple and Windows Org at Microsoft, two groups who hate tests and live in the late 90s.
  4. Testability is Rad Now, we can test UIs just by

    creating ViewModels, and be mostly sure that our UI will work.
  5. Cocoa in five minutes NIBs are like XAML files, the

    framework reads it on startup and creates some objects for you.
  6. Cocoa in five minutes Instead of controls having events, they

    have an object that receives the events, called a delegate.
  7. Cocoa-style MVC “Controller objects are thus a conduit through which

    view objects learn about changes in model objects and vice versa."
  8. Cocoa-style MVC "A controller object interprets user actions made in

    view objects and communicates new or changed data to the model layer. When model objects change, a controller object communicates that new model data to the view objects so that they can display it."
  9. Cocoa-style MVC Because ViewControllers have outlets to actual UI controls,

    they’re not easy to test, treat the ‘C’ in MVC like you treat the XAML Code-Behind.