Rx.NET

pour ceux qui connaissent déjà RxJS

Le typage...

Les opérateurs

Pas de Map...
... ni de FlatMap

Les expressions LINQ

			
from quote in quotes
where quote.Symbol == "MSFT"
select quote;
			
		

Les expressions LINQ

			
from market in markets
from quote in market.quotes
where quote.Symbol == "MSFT"
select quote;
			
		

Jointures et Rx...

			
from start in mouseDown
join move in mouseMove
on mouseUp equals Observable.Empty<Unit>() into moveGroup
			
		

BART DE SMET'S ON-LINE BLOG

A partir de

'event' .NET
Anciennes API async APM
Task,
et IEnumerable

Création d'Observable

		
var obs = Read().ToObservable();

IEnumerable<string> Read() {
	while (true)
		yield return Console.ReadLine();
}

		
	

Lien avec async/await

			
				await myObservable;
			
		

Des threads et plus de schedulers

ImmediateScheduler
CurrentThreadScheduler
TaskPoolScheduler

NO LOCK!

EventLoopScheduler FTW

A propos de schedulers...

ObserveOn ?

SubscribeOn ?

Ca imprime quoi ?

			
Observable.Range(1, 10)
	.ObserveOn(Scheduler.TaskPool)
	.Subscribe(
	    x =>
	    {
	        Thread.Sleep(1000 - (100 * x));
	        Console.Out.WriteLine( x 
	        	+ "  in thread " 
	        	+ Thread.CurrentThread.ManagedThreadId);
	    }
	);
	
	

Rx ça sérialise !

			
1  in thread 8
2  in thread 9
3  in thread 8
4  in thread 8
5  in thread 14
6  in thread 9
7  in thread 13
8  in thread 9
9  in thread 14
10  in thread 9

	

... dans le doute

Observable.Synchronize()