Last active
August 29, 2015 13:56
-
-
Save forki/8902210 to your computer and use it in GitHub Desktop.
Rx + async
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void RegisterConnection(string connectionId, string company, string processId) | |
{ | |
var observable = | |
Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(2)) | |
.SelectMany(_ => Observable.FromAsync(() => ProcessService.GetProcessChangeTimeAsync(company, processId))) | |
.Distinct() | |
.SelectMany(_ => Observable.FromAsync(() => ProcessService.GetDiagramDataAsync(company, processId))); | |
var subscription = observable.Subscribe(json => _hub.Clients.Client(connectionId).loadProcess(json)); | |
Subscriptions.Add(connectionId, subscription); | |
} |
I think there's a SelectMany
overload that takes a Task<T>
, so you can loose the Observable.FromAsync
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
second version. SelectMany instead of Select + concat
But still why do I have to use Observable.FromAsync and the SelectMany - why no overload at Select which takes an async method