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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think there's a
SelectMany
overload that takes aTask<T>
, so you can loose theObservable.FromAsync
.