コード例 #1
0
        public static ReactiveCommandWithHistory <TParam, TResult> CreateWithHistoryFromObservable <TParam, TResult>(
            string commandKey,
            Func <TParam, TResult, IObservable <TResult> > execute,
            Func <TParam, TResult, IObservable <TResult> > discard,
            IHistory history,
            IObservable <bool>?canExecute = null,
            IScheduler?outputScheduler    = null)
        {
            if (history == null)
            {
                throw new ArgumentNullException(nameof(history));
            }
            if (discard == null)
            {
                throw new ArgumentNullException(nameof(discard));
            }
            if (execute == null)
            {
                throw new ArgumentNullException(nameof(execute));
            }

            return(CreateWithHistoryFromObservable(
                       commandKey, execute, discard,
                       HistoryContext.GetContext(history, outputScheduler),
                       canExecute, outputScheduler));
        }
コード例 #2
0
 public static ReactiveCommandWithHistory <TParam, TResult> CreateWithHistory <TParam, TResult>(
     string commandKey,
     Func <TParam, TResult, TResult> execute,
     Func <TParam, TResult, TResult> discard,
     IObservable <bool>?canExecute = null,
     IScheduler?outputScheduler    = null,
     string historyId = "")
 {
     return(new ReactiveCommandWithHistory <TParam, TResult>(commandKey,
                                                             (param, result) => Observable.Create <TResult>(
                                                                 observer =>
     {
         observer.OnNext(execute(param, result));
         observer.OnCompleted();
         return new CompositeDisposable();
     }),
                                                             (param, result) => Observable.Create <TResult>(
                                                                 observer =>
     {
         observer.OnNext(discard(param, result));
         observer.OnCompleted();
         return new CompositeDisposable();
     }),
                                                             HistoryContext.GetContext(historyId, outputScheduler),
                                                             canExecute ?? Observables.True,
                                                             outputScheduler ?? RxApp.MainThreadScheduler));
 }