execute method
- @override
Calls the wrapped handler function with an option input parameter
Implementation
@override
execute([TParam param])
{
// print("************ Execute***** canExecute: $_canExecute ***** isExecuting: $_isRunning");
if (!_canExecute)
{
return;
}
if (_isRunning)
{
return;
}
else
{
_isRunning = true;
_canExecuteSubject.add(false);
}
_isExecutingSubject.add(true);
_func(param).asStream()
.handleError((error)
{
if (!_thrownExceptionsSubject.hasListener)
{
_resultsSubject.addError(error);
}
if (error is Exception)
{
_thrownExceptionsSubject.add(error);
}
else
{
_thrownExceptionsSubject.add(new Exception(error.toString()));
}
_isRunning = false;
_isExecutingSubject.add(false);
_canExecuteSubject.add(true);
})
.take(1)
.listen( (result) {
_resultsSubject.add(result);
_isRunning = false;
_isExecutingSubject.add(false);
_canExecuteSubject.add(true);
});
}