Skip to content

Instantly share code, notes, and snippets.

@RolandPheasant
Last active November 7, 2017 21:43
Show Gist options
  • Save RolandPheasant/588e2196d83c875fa8dcea9aebe4edd9 to your computer and use it in GitHub Desktop.
Save RolandPheasant/588e2196d83c875fa8dcea9aebe4edd9 to your computer and use it in GitHub Desktop.
public static class ObservableEx
{
public static IObservable<IChangeSet<T>> BufferInitial<T>(this IObservable<IChangeSet<T>> source, TimeSpan initalBuffer, IScheduler scheduler = null)
{
return source.DeferUntilLoaded().Publish(shared =>
{
var initial = shared.Buffer(initalBuffer, scheduler ?? Scheduler.Default)
.FlattenBufferResult()
.Take(1);
return initial.Concat(shared);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment