I have a ViewModel
with some ReactiveCommands
that user can invoke manually.
CommandA
CommandB
CommandC
So the user can invoke only B, or A first, and then C.
The problem is that there is that I want to create another command that runs them in order, from A to C. They shouldn't run in parallel, but sequentially.
How can I do a command of the given characteristics?
Since you want them executed sequentially,
ReactiveCommand.CreateCombined
isn't really a good fit. However, you could create something similar to CombinedReactiveCommand to work for your situation.Reactive commands can be executed manually by calling
ReactiveCommand<TParam,TResult>.Execute
, which returns anIObservable<TResult>
that returns a single value. Therefore, a very basic implementation could just chain it to other execute calls withSelectMany
:If all of your commands have the same type, it could be made more generic:
However, this does not take into consideration the other things CombinedReactiveCommand handles, such as
CanExecute
andThrownExceptions
. If you need to handle those, then you might consider rolling your own CombinedReactiveCommand.