Reactive Xamarin
Olexandr Leuschenko
uamobile 2016
Everything
is an
object
Alan Kay
Everything
is a stream
of objects!
Streams
are
observable
represent data as streams with observables
!
query with LINQ
!
rule the concurrency with schedulers
Observables + LINQ +
Schedulers
Rx =
Observables + LINQ + Schedulers
Reactive Xamarin =
Rx + Xamarin
Q & A
Agenda
• What is Observable?
• What about LINQ?
• Master time with Schedulers
• Why bother?
Agenda
• What is Observable?
• What about LINQ?
• Master time with Schedulers
• Why bother?
stream is a collection
collection is a stream
IEnumerator
• object Current { get; }
• bool MoveNext ();
• void Reset ();
PULL
PULL
PUSH
IObserver
• void OnNext (T value);
• void OnCompeted ();
• void OnError (Exception exception);
PULL vs PUSH
SYNC vs ASYNC
I have TPL
Single Value Multiple Values
SYNC T IEnumerable<T>
ASYNC Task<T> IObservable<T>
How to create Observables?
• Factory Methods
◦ Observable.Return
◦ Observable.Empty
◦ Observable.Never
◦ Observable.Throw
◦ Observable.Create
• Unfold methods
◦ Observable.Range
◦ Observable.Interval
◦ Observable.Timer
◦ Observable.Generate
• Paradigm Transition
◦ Observable.Start
◦ Observable.FromEventPattern
◦ Task.ToObservable
◦ Task<T>.ToObservable
◦ IEnumerable<T>.ToObservable
◦ Observable.FromAsyncPattern
Tiny demo
Agenda
• What is Observable?
• What about LINQ?
• Master time with Schedulers
• Why bother?
Reactive LINQ is like
LINQ, but Reactive
LINQ & Observables
RxMarbles
http://rxmarbles.com
Agenda
• What is Observable?
• What about LINQ?
• Master time with Schedulers
• Why bother?
Events are single-
thread
Rx is single-thread
Schedulers
• ImmediateScheduler — will start the specified
action immediately
• CurrentThreadScheduler — will schedule action to
be performed on the thread that makes the original
call
• DispatcherScheduler — will scheduler action on the
current Dispatcher
• …
TimeScheduler
Teeny-weeny Demo
Agenda
• What is Observable?
• What about LINQ?
• Master time with Schedulers
• Why bother?
Reactive UI
• UI-friendly extension methods
• Base ViewModel
• Base View
• DI
• Logging
• Supports Xamarin.iOS, Xamarin.Android, Xamarin.Mac,
Xamarin Forms, WPF, Windows Forms, Windows Phone 8,
Windows Store and Universal Windows Platform (UWP)
Reactive UI
• UI-friendly extension methods
• Base ViewModel
• Base View
• DI
• Logging
• Supports Xamarin.iOS, Xamarin.Android, Xamarin.Mac,
Xamarin Forms, WPF, Windows Forms, Windows Phone 8,
Windows Store and Universal Windows Platform (UWP)
Reactive UI
• UI-friendly extension methods
• Base ViewModel
• Base View
• DI
• Logging
• Supports Xamarin.iOS, Xamarin.Android, Xamarin.Mac,
Xamarin Forms, WPF, Windows Forms, Windows Phone 8,
Windows Store and Universal Windows Platform (UWP)
RxLite
• UI-friendly extension methods
• Optional base ViewModel
RxLite Simple Rules
• One-Way binding — ObservableAsProperty
• Two-Way binding — property with RaiseAndSetIfChanged
• Command — ReactiveCommand
Reactive UI
RxLite
So?
Playground demo
https://github.com/OlexaLe/RxLite
Thanks!
• olexa.le@gmail.com
• http://twitter.com/olexale
Q&A
olexa.le@gmail.com http://twitter.com/olexale

Reactive Xamarin. UA Mobile 2016.