Slide 1

Slide 1 text

MVVM Without XAML

Slide 2

Slide 2 text

A Login Dialog is A Login Dialog is A Login Dialog Alternate Title:

Slide 3

Slide 3 text

How to write the same code and have it run everywhere Alternate Title:

Slide 4

Slide 4 text

@ xpaulbettsx

Slide 5

Slide 5 text

these look different

Slide 6

Slide 6 text

but they mostly act the same.

Slide 7

Slide 7 text

“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.”

Slide 8

Slide 8 text

We should be able to share that code everywhere

Slide 9

Slide 9 text

What this talk is not about.

Slide 10

Slide 10 text

MVVM

Slide 11

Slide 11 text

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.

Slide 12

Slide 12 text

MVVM In A Nutshell ViewModels are Properties and Commands.

Slide 13

Slide 13 text

Testability is Rad Now, we can test UIs just by creating ViewModels, and be mostly sure that our UI will work.

Slide 14

Slide 14 text

You’re doing MVVM right if you write a UI without ever seeing the XAML Designer.

Slide 15

Slide 15 text

So...

Slide 16

Slide 16 text

If ViewModels don’t know about views...

Slide 17

Slide 17 text

...then why can’t we reuse them?

Slide 18

Slide 18 text

What about Bindings?

Slide 19

Slide 19 text

ReactiveUI ReactiveUI is a cross-platform MVVM framework, built around the Reactive Extensions

Slide 20

Slide 20 text

ReactiveUI has its own bindings

Slide 21

Slide 21 text

ReactiveUI has its own bindings

Slide 22

Slide 22 text

ReactiveUI has its own bindings

Slide 23

Slide 23 text

ReactiveUI has its own bindings

Slide 24

Slide 24 text

So why not a MVVM WinForms app?

Slide 25

Slide 25 text

(demo)

Slide 26

Slide 26 text

A brief introduction to Xamarin.Mac

Slide 27

Slide 27 text

Cocoa in five minutes NIBs are like XAML files, the framework reads it on startup and creates some objects for you.

Slide 28

Slide 28 text

Cocoa in five minutes Instead of controls having events, they have an object that receives the events, called a delegate.

Slide 29

Slide 29 text

a brief introduction to Cocoa- style MVC and why it’s not great

Slide 30

Slide 30 text

Cocoa-style MVC “Controller objects are thus a conduit through which view objects learn about changes in model objects and vice versa."

Slide 31

Slide 31 text

Awesome!

Slide 32

Slide 32 text

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."

Slide 33

Slide 33 text

Totally Rad!

Slide 34

Slide 34 text

Cocoa-style MVC "Controllers directly reference UI controls through outlets to fiddle with their contents."

Slide 35

Slide 35 text

ಠ_ಠ

Slide 36

Slide 36 text

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.

Slide 37

Slide 37 text

let’s apply MVVM to Cocoa

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

(demo)