Ejemplo n.º 1
0
        /// <summary>
        /// Subscribe execute.
        /// </summary>
        /// <typeparam name="T">AsyncReactiveCommand type argument.</typeparam>
        /// <param name="self">AsyncReactiveCommand</param>
        /// <param name="asyncAction">Action</param>
        /// <param name="postProcess">Handling of the subscription.</param>
        /// <returns>Same of self argument</returns>
        public static AsyncReactiveCommand <T> WithSubscribe <T>(this AsyncReactiveCommand <T> self, Func <T, Task> asyncAction, Action <IDisposable> postProcess = null)
        {
            var d = self.Subscribe(asyncAction);

            postProcess?.Invoke(d);
            return(self);
        }
Ejemplo n.º 2
0
 public Subscription(AsyncReactiveCommand <T> parent, Func <T, Task> asyncAction)
 {
     this.parent      = parent;
     this.asyncAction = asyncAction;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Subscribe execute.
 /// </summary>
 /// <typeparam name="T">AsyncReactiveCommand type argument.</typeparam>
 /// <param name="self">AsyncReactiveCommand</param>
 /// <param name="asyncAction">Action</param>
 /// <param name="disposable">The return value of self.Subscribe(asyncAction)</param>
 /// <returns>Same of self argument</returns>
 public static AsyncReactiveCommand <T> WithSubscribe <T>(this AsyncReactiveCommand <T> self, Func <T, Task> asyncAction, out IDisposable disposable)
 {
     disposable = self.Subscribe(asyncAction);
     return(self);
 }
 /// <summary>
 /// Command binding method.
 /// </summary>
 /// <typeparam name="T">IObservable type</typeparam>
 /// <param name="self">IObservable</param>
 /// <param name="command">Command</param>
 /// <returns>Command binding token</returns>
 public static IDisposable SetCommand <T>(this IObservable <T> self, AsyncReactiveCommand command) =>
 self
 .Where(_ => command.CanExecute())
 .Subscribe(x => command.Execute());