/// <summary>
 /// RegisterAsyncAction registers an asynchronous method that runs
 /// whenever the Command's Execute method is called and doesn't return a
 /// result.
 /// </summary>
 /// <param name="calculationFunc">The function to be run in the
 /// background.</param>
 public static IObservable <Unit> RegisterAsyncAction(this IReactiveCommand This,
                                                      Action <object> calculationFunc,
                                                      IScheduler scheduler = null)
 {
     Contract.Requires(calculationFunc != null);
     return(This.RegisterAsyncFunction(x => { calculationFunc(x); return new Unit(); }, scheduler));
 }
Example #2
0
        /// <summary>
        /// RegisterAsyncAction registers an asynchronous method that runs
        /// whenever the Command's Execute method is called and doesn't return a
        /// result.
        /// </summary>
        /// <param name="calculationFunc">The function to be run in the
        /// background.</param>
        public static IObservable <Unit> RegisterAsyncAction(this IReactiveCommand This,
                                                             Action <object> calculationFunc,
                                                             IScheduler scheduler = null)
        {
            Contract.Requires(calculationFunc != null);

            // NB: This PermaRef isn't exactly correct, but the people using
            // this method probably are Doing It Wrong, so let's let them
            // continue to do so.
            return(This.RegisterAsyncFunction(x => { calculationFunc(x); return new Unit(); }, scheduler)
                   .Publish().PermaRef());
        }