RxCommand<TParam, TRESULT> constructor

RxCommand<TParam, TRESULT>(BehaviorSubject<CommandResult<TRESULT>> _commandResultsSubject, Observable<bool> canExecuteRestriction)

Implementation

RxCommand(this._commandResultsSubject, Observable<bool> canExecuteRestriction):super(_commandResultsSubject.observable)
{
    this
      .where( (x) => x.hasError)
        .listen((x) => _thrownExceptionsSubject.add(x.error));

    this
      .listen((x) => _isExecutingSubject.add(x.isExecuting));

     var _canExecuteParam = canExecuteRestriction == null ? new Observable.just(true)
                                                : canExecuteRestriction.handleError((error)
                                                  {
                                                      if (error is Exception)
                                                      {
                                                        _thrownExceptionsSubject.add(error);
                                                      }
                                                  })
                                                  .distinct();



    _canExecuteParam.listen((canExecute){
      _canExecute = canExecute && (!_isRunning);
      _canExecuteSubject.add(_canExecute);
    });


}