public static IObservable <bool> GetIsActivated(this ISupportsActivation @this) =>
 Observable
 .Merge(
     @this.Activator.Activated.Select(_ => true),
     @this.Activator.Deactivated.Select(_ => false))
 .Replay(1)
 .RefCount();
예제 #2
0
 /// <summary>
 /// WhenActivated allows you to register a Func to be called when a
 /// ViewModel's View is Activated.
 /// </summary>
 /// <param name="This">Object that supports activation.</param>
 /// <param name="block">The method to be called when the corresponding
 /// View is activated. The Action parameter (usually called 'disposables') allows
 /// you to collate all the disposables to be cleaned up during deactivation.</param>
 public static void WhenActivated(this ISupportsActivation This, Action <CompositeDisposable> block)
 {
     This.Activator.addActivationBlock(() => {
         var d = new CompositeDisposable();
         block(d);
         return(new[] { d });
     });
 }
예제 #3
0
 /// <summary>
 /// WhenActivated allows you to register a Func to be called when a
 /// ViewModel's View is Activated.
 /// </summary>
 /// <param name="This">Object that supports activation.</param>
 /// <param name="block">The method to be called when the corresponding
 /// View is activated. The Action parameter (usually called 'd') allows
 /// you to register Disposables to be cleaned up when the View is
 /// deactivated (i.e. "d(someObservable.Subscribe());")</param>
 public static void WhenActivated(this ISupportsActivation This, Action <Action <IDisposable> > block)
 {
     This.Activator.addActivationBlock(() => {
         var ret = new List <IDisposable>();
         block(ret.Add);
         return(ret);
     });
 }
        public static IObservable <bool> GetIsActivated(this ISupportsActivation @this)
        {
            Ensure.ArgumentNotNull(@this, nameof(@this));

            return(Observable
                   .Merge(
                       @this.Activator.Activated.Select(_ => true),
                       @this.Activator.Deactivated.Select(_ => false))
                   .Replay(1)
                   .RefCount());
        }
예제 #5
0
        public static void WhenActivated(
            this ISupportsActivation @this,
            Action <CompositeDisposable> disposables)
        {
            @this.AssertNotNull(nameof(@this));

            @this
            .WhenActivated(
                () =>
            {
                var d = new CompositeDisposable();
                disposables(d);
                return(new[] { d });
            });
        }
        public static void WhenActivated(this ISupportsActivation source, IHTMLElement element, IStyle.DisplayEnum display)
        {
            element.style.display = IStyle.DisplayEnum.none;

            source.Activated +=
                delegate
            {
                element.style.display = display;
            };

            source.Deactivated +=
                delegate
            {
                element.style.display = IStyle.DisplayEnum.none;
            };
        }
        public static void WhenActivated(
            this ISupportsActivation @this,
            Action <CompositeDisposable> disposables)
        {
            if (@this == null)
            {
                throw new ArgumentNullException("this");
            }

            @this.WhenActivated(
                () =>
            {
                var d = new CompositeDisposable();
                disposables(d);
                return(new[] { d });
            });
        }
예제 #8
0
 /// <summary>
 /// WhenActivated allows you to register a Func to be called when a
 /// ViewModel's View is Activated.
 /// </summary>
 /// <param name="This">Object that supports activation.</param>
 /// <param name="block">The method to be called when the corresponding
 /// View is activated. It returns a list of Disposables that will be
 /// cleaned up when the View is deactivated.</param>
 public static void WhenActivated(this ISupportsActivation This, Func <IEnumerable <IDisposable> > block)
 {
     This.Activator.addActivationBlock(block);
 }
 public static void WhenActivated(this ISupportsActivation source, IHTMLElement element)
 {
     WhenActivated(source, element, IStyle.DisplayEnum.empty);
 }
예제 #10
0
 public static void WhenActivated(this ISupportsActivation source, Action action)
 {
     source.WhenActivated(compositeDisposable => WhenActivatedDummy(compositeDisposable, action));
 }
예제 #11
0
 public static void WhenActivated(this ISupportsActivation This, params Func <IEnumerable <IDisposable> >[] blocks)
 {
     ViewForMixins.WhenActivated(This, () => blocks.SelectMany(x => x()));
 }
예제 #12
0
 public static IDisposable WithActivation(this ISupportsActivation This)
 {
     This.Activator.Activate();
     return(Disposable.Create(This.Activator.Deactivate));
 }