Skip to content

Instantly share code, notes, and snippets.

@yuka1984
Created April 22, 2016 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuka1984/9fb1afb3dd75007e8bde498eead908ef to your computer and use it in GitHub Desktop.
Save yuka1984/9fb1afb3dd75007e8bde498eead908ef to your computer and use it in GitHub Desktop.
RxSyncTimeout.cs
public static IObservable<TResult> SyncTimeout<TSource, TResult>(this IObservable<TSource> first,
IObservable<TSource> second, TimeSpan dueTime, Func<TSource, TSource, TResult> selectorFunc)
{
return
first
.Zip(second.Timeout(dueTime).Take(1), (f, s) => new {First = f, Second = s})
.Repeat()
.Select(x => selectorFunc(x.First, x.Second));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment