diff options
author | Dennis Kobert <d-kobert@web.de> | 2019-06-11 23:38:13 +0200 |
---|---|---|
committer | Dennis Kobert <d-kobert@web.de> | 2019-06-11 23:38:13 +0200 |
commit | 2fa4a0e50ebfc97059c8b84dbd17e79f9afc8a8d (patch) | |
tree | c3b34ccb2737e347a73768536895cbbaab13cc01 /FireBase/Extensions | |
parent | ec991104f56e90d7bb2878da2fe6ed4e585dfc46 (diff) | |
parent | af74efccf8d21e6151022b71f3cacd3fa83024ee (diff) |
Merge branch 'rework-backend'
Diffstat (limited to 'FireBase/Extensions')
-rw-r--r-- | FireBase/Extensions/ObservableExtensions.cs | 40 | ||||
-rw-r--r-- | FireBase/Extensions/TaskExtensions.cs | 23 |
2 files changed, 0 insertions, 63 deletions
diff --git a/FireBase/Extensions/ObservableExtensions.cs b/FireBase/Extensions/ObservableExtensions.cs deleted file mode 100644 index 12cd5f3..0000000 --- a/FireBase/Extensions/ObservableExtensions.cs +++ /dev/null @@ -1,40 +0,0 @@ -namespace Firebase.Database.Extensions -{ - using System; - using System.Reactive.Linq; - - public static class ObservableExtensions - { - /// <summary> - /// Returns a cold observable which retries (re-subscribes to) the source observable on error until it successfully terminates. - /// </summary> - /// <param name="source">The source observable.</param> - /// <param name="dueTime">How long to wait between attempts.</param> - /// <param name="retryOnError">A predicate determining for which exceptions to retry. Defaults to all</param> - /// <returns> - /// A cold observable which retries (re-subscribes to) the source observable on error up to the - /// specified number of times or until it successfully terminates. - /// </returns> - public static IObservable<T> RetryAfterDelay<T, TException>( - this IObservable<T> source, - TimeSpan dueTime, - Func<TException, bool> retryOnError) - where TException: Exception - { - int attempt = 0; - - return Observable.Defer(() => - { - return ((++attempt == 1) ? source : source.DelaySubscription(dueTime)) - .Select(item => new Tuple<bool, T, Exception>(true, item, null)) - .Catch<Tuple<bool, T, Exception>, TException>(e => retryOnError(e) - ? Observable.Throw<Tuple<bool, T, Exception>>(e) - : Observable.Return(new Tuple<bool, T, Exception>(false, default(T), e))); - }) - .Retry() - .SelectMany(t => t.Item1 - ? Observable.Return(t.Item2) - : Observable.Throw<T>(t.Item3)); - } - } -} diff --git a/FireBase/Extensions/TaskExtensions.cs b/FireBase/Extensions/TaskExtensions.cs deleted file mode 100644 index 26bbde6..0000000 --- a/FireBase/Extensions/TaskExtensions.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Firebase.Database.Extensions -{ - using System; - using System.Threading.Tasks; - - public static class TaskExtensions - { - /// <summary> - /// Instead of unwrapping <see cref="AggregateException"/> it throws it as it is. - /// </summary> - public static async Task WithAggregateException(this Task source) - { - try - { - await source.ConfigureAwait(false); - } - catch (Exception ex) - { - throw source.Exception ?? ex; - } - } - } -} |