From 1d9a224e0b6a70679218fc1385c744383c9e9820 Mon Sep 17 00:00:00 2001 From: helto4real Date: Fri, 28 Aug 2020 13:03:35 +0200 Subject: [PATCH] Default not specify timeout value --- .../Common/Reactive/ObservableExtensionMethods.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/App/NetDaemon.App/Common/Reactive/ObservableExtensionMethods.cs b/src/App/NetDaemon.App/Common/Reactive/ObservableExtensionMethods.cs index d29ddc625..59eafacbf 100644 --- a/src/App/NetDaemon.App/Common/Reactive/ObservableExtensionMethods.cs +++ b/src/App/NetDaemon.App/Common/Reactive/ObservableExtensionMethods.cs @@ -20,14 +20,23 @@ public static IObservable<(EntityState Old, EntityState New)> NDSameStateFor(thi } /// - /// Is same for timespan time + /// Wait for state the specified /// /// /// Timeout waiting for state - /// - public static IObservable<(EntityState Old, EntityState New)> NDFirstOrTimeout(this IObservable<(EntityState Old, EntityState New)> observable, TimeSpan timeout) + public static IObservable<(EntityState Old, EntityState New)> NDWaitForState(this IObservable<(EntityState Old, EntityState New)> observable, TimeSpan timeout) { return observable.Timeout(timeout, Observable.Return((new NetDaemon.Common.EntityState() { State = "TimeOut" }, new NetDaemon.Common.EntityState() { State = "TimeOut" }))).Take(1); } + + /// + /// Wait for state the default time + /// + /// + public static IObservable<(EntityState Old, EntityState New)> NDWaitForState(this IObservable<(EntityState Old, EntityState New)> observable) + { + return observable.Timeout(TimeSpan.FromSeconds(5), Observable.Return((new NetDaemon.Common.EntityState() { State = "TimeOut" }, new NetDaemon.Common.EntityState() { State = "TimeOut" }))).Take(1); + } + } } \ No newline at end of file