Does anybody know how to track the fact that reactive command has finished its execution and hook up the method, which will start running after that?
P.S. The variant when calling the method in the end of the command's handler method does not fit in my situation.
Thanks in advance!
ReactiveCommand has an observable property called IsExecuting
that can be used to observe when the command is being executed. One way to handle this case would be doing something like this:
YourCommand.IsExecuting
.Skip(1) // IsExecuting has an initial value of false. We can skip that first value
.Where(isExecuting => !isExecuting) // filter until the executing state becomes false
.Subscribe(_ => YourMethodCall()); // run your method now that the command is done
Eugene is totally right, but I wanted to mention an alternative option. If your command only returns one value (as most commands do), you can hook into the command itself is an observable that ticks the result of every successful execution:
YourCommand.Subscribe(result => YourMethodCall(result));
The advantage here is you now have access to the command's result in YourMethodCall
.