/// <summary> /// Observe changes to the AppState of a class derived from ISuspensionHost. /// </summary> /// <typeparam name="T">The observable type.</typeparam> /// <param name="item">The suspension host.</param> /// <returns>An observable of the app state.</returns> public static IObservable <T> ObserveAppState <T>(this ISuspensionHost item) where T : class { return(item.WhenAny(suspensionHost => suspensionHost.AppState, observedChange => observedChange.Value) .Where(x => x != null) .Cast <T>()); }
/// <summary> /// Observe changes to the AppState of a class derived from ISuspensionHost. /// </summary> /// <typeparam name="T">The observable type.</typeparam> /// <param name="item">The suspension host.</param> /// <returns>An observable of the app state.</returns> public static IObservable <T> ObserveAppState <T>(this ISuspensionHost item) where T : class { if (item is null) { throw new ArgumentNullException(nameof(item)); } return(item.WhenAny(suspensionHost => suspensionHost.AppState, observedChange => observedChange.Value) .WhereNotNull() .Cast <T>()); }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="This"></param> /// <returns></returns> public static IObservable <T> ObserveAppState <T>(this ISuspensionHost This) { return(This.WhenAny(x => x.AppState, x => (T)x.Value) .Where(x => x != null)); }
/// <summary> /// Observe changes to the AppState of a class derived from ISuspensionHost. /// </summary> /// <typeparam name="T">The observable type.</typeparam> /// <param name="item">The suspension host.</param> /// <returns>An observable of the app state.</returns> public static IObservable <T> ObserveAppState <T>(this ISuspensionHost item) where T : class { return(item.WhenAny(x => x.AppState, x => (T)x.Value) .Where(x => x != null)); }