createSync3<TParam, TResult> method
Creates a RxCommand for a synchronous handler function with parameter that returns a value
func
: handler function
canExecute
: observable that can bve used to enable/diable the command based on some other state change
if omitted the command can be executed always except it's already executing
isExecuting will issue a bool
value on each state change. Even if you
subscribe to a newly created command it will issue false
emitLastResult
will include the value of the last successful execution in all CommandResult events unless there is no new result.
For the Observable<CommandResult>
that RxCommand implement this normally doesn't make sense
if you want to get an initial Result with data==null, error==null, isExceuting==false
pass
emitInitialCommandResult=true
.
Implementation
/// [isExecuting] will issue a `bool` value on each state change. Even if you
/// subscribe to a newly created command it will issue `false`
/// [emitLastResult] will include the value of the last successful execution in all [CommandResult] events unless there is no new result.
/// For the `Observable<CommandResult>` that [RxCommand] implement this normally doesn't make sense
/// if you want to get an initial Result with `data==null, error==null, isExceuting==false` pass
/// [emitInitialCommandResult=true].
static RxCommand<TParam, TResult> createSync3<TParam, TResult>(Func1<TParam,TResult> func,{Observable<bool> canExecute, bool emitInitialCommandResult = false, bool emitLastResult=false})
{
return new RxCommandSync<TParam,TResult>((x) => func(x),canExecute,emitInitialCommandResult,emitLastResult);
}