trySingle property

RxResult<T> get trySingle

Implementation

RxResult<T> get trySingle {
  return RxResult.tryExecute(() {
    if (value.isEmpty) {
      throw const RxException('Cannot get single element of empty set');
    }
    if (value.length > 1) {
      throw const RxException('Set has more than one element');
    }
    return value.single;
  }, 'get single element from set');
}