Slide 1

Slide 1 text

Reactive Extensions and ReactiveUI

Slide 2

Slide 2 text

github @xpaulbettsx

Slide 3

Slide 3 text

A Model-View-ViewModel framework for native (non-web) applications.. ...that integrates the Reactive Extensions for .NET. What is ReactiveUI

Slide 4

Slide 4 text

Write completely non-blocking UIs whose interactions are described in a declarative fashion, and be able to test long-running timelines instantly using virtual time Why is that cool?

Slide 5

Slide 5 text

Not just limited to XAML! • ReactiveUI works even on non-XAML platforms • Preliminary support for Cocoa / UIKit, GTK#, and Android • Runs on .NET 4.0, .NET 4.5, Silverlight 5, WP7, WP8, Metro / WinRT, and Mono

Slide 6

Slide 6 text

Code in XAML code-behind is untestable - let’s move as much of our behavior into a separate object that we can test, and abstract away commands from how they’re invoked (button clicks) MVVM

Slide 7

Slide 7 text

ReactiveUI bridges Properties and Observables

Slide 8

Slide 8 text

WhenAny

Slide 9

Slide 9 text

WhenAny

Slide 10

Slide 10 text

WhenAny

Slide 11

Slide 11 text

WhenAny

Slide 12

Slide 12 text

How WhenAny Works • WhenAny determines at runtime how to be notified for a property change on an object • INotifyPropertyChanged • DependencyObjects (XAML) • Key-Value Observing (Cocoa)

Slide 13

Slide 13 text

ToProperty

Slide 14

Slide 14 text

ToProperty

Slide 15

Slide 15 text

OAPH • Subscribes to an IObservable for you and “pipes” it to a property • Makes sure that notifications come back on the UI thread

Slide 16

Slide 16 text

WhenAny and ToProperty fit together like tea and crumpets

Slide 17

Slide 17 text

WhenAny + ToProperty

Slide 18

Slide 18 text

WhenAny + ToProperty

Slide 19

Slide 19 text

WhenAny + ToProperty

Slide 20

Slide 20 text

ReactiveUI bridges Commands and Observables

Slide 21

Slide 21 text

ReactiveCommand = Subject + ICommand • Implements WPF’s ICommand • Is also an IObservable

Slide 22

Slide 22 text

ReactiveCommand

Slide 23

Slide 23 text

ReactiveCommand helps you to decouple Views and ViewModels

Slide 24

Slide 24 text

Doesn’t ICommand have a CanExecute too?

Slide 25

Slide 25 text

CanExecute is IObservable • You can source this IObservable from anywhere • One particularly useful place, is from WhenAny

Slide 26

Slide 26 text

CanExecute

Slide 27

Slide 27 text

Demo!