much of our behavior into a separate object that we can test, and abstract away commands from how they’re invoked (button clicks) MVVM Tuesday, December 27, 11
(IEnumerable) • Operators create a “pipeline” - you put stuff in, get stuff out • new[] {1,2,3,4} .Where(x => x % 2 == 0) .Select(x => x * 10); >>> [20, 40] Tuesday, December 27, 11
Sequences. • If IEnumerable<T> is a “list”, IObservable<T> is a “Future List” • IObservable<T> has exactly one method: IDisposable Subscribe(IObserver<T> subscriber) Tuesday, December 27, 11
return Task<T>, Rx async methods always return IObservable<T> public IObservable<int> AsyncAdd(int a, int b) { return Observable.Start(() => return a+b); } Tuesday, December 27, 11
back var result = asyncCall(17).First(); // Get the result async asyncCall(42).Subscribe(x => /* Do Stuff */); // Let’s try a list var results = new[]{17, 42, 87}.ToObservable() .SelectMany(x => asyncCall(x)) .ToList().First(); Tuesday, December 27, 11
main things • An object that can be Observed (ReactiveObject) • An ICommand which implements IObservable • A collection that can be Observed (ReactiveCollection<T>) Tuesday, December 27, 11