/// <summary> /// Once /// </summary> /// <param name="activity"></param> /// <returns></returns> public static IObservable <ActivityState> OnDestroying(this ActivityBase activity) { return(activity .Events .Where(e => e.Key == nameof(ActivityBase.ActivityState)) .Select(x => (ActivityState)x.Value) .Where(state => state == ActivityState.Destroying) .Take(1)); }
/// <summary> /// TODO: -> NotificationManager IsDisable(INotification) /// </summary> public static IDisposable SubscribeNotification( this ActivityBase activity, IObservable <IEvent> activityEvents, INotification notification) { var waiting = false; var enabled = true; var source = new CancellationTokenSource(); return(activityEvents .Select(x => new { waiting, enabled, // activity.ActivityState, activity.IsDestroyed, source.IsCancellationRequested }) .Where(x => !x.waiting) .Do(x => { if (!x.IsCancellationRequested && x.IsDestroyed) { source.Cancel(); } }) .TakeWhile(x => x.enabled && // it's Disabled ? !x.IsDestroyed && !x.IsCancellationRequested) .Subscribe(async x => { var result = await notification.Notify(activity, source.Token); enabled = !result.Ok; waiting = false; if (source.IsCancellationRequested) { return; } source.Cancel(); })); }
public FragmentNavigator(ActivityBase activity, IFragmentFactory fragmentFactory) { _activity = activity; _fragmentFactory = fragmentFactory; }
public INavigator Create(ActivityBase activity) { return(new FragmentNavigator(activity, Container.Resolve <FragmentFactory>())); }
public static IObservable <IEvent> WhenBackPressed(this ActivityBase activity) { return(activity.Events.Where(e => e.Key == nameof(activity.OnBackPressed))); }