Reactive-Extensions/RxJS

View on GitHub
src/core/perf/operators/ignoreelements.js

Summary

Maintainability
D
2 days
Test Coverage
Function `IgnoreElementsObservable` has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Function `IgnoreElementsObservable` has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Similar blocks of code found in 3 locations. Consider refactoring.
var IgnoreElementsObservable = (function(__super__) {
inherits(IgnoreElementsObservable, __super__);
 
function IgnoreElementsObservable(source) {
this.source = source;
__super__.call(this);
}
 
IgnoreElementsObservable.prototype.subscribeCore = function (o) {
return this.source.subscribe(new InnerObserver(o));
};
 
function InnerObserver(o) {
this.o = o;
this.isStopped = false;
}
InnerObserver.prototype.onNext = noop;
InnerObserver.prototype.onError = function (err) {
if(!this.isStopped) {
this.isStopped = true;
this.o.onError(err);
}
};
InnerObserver.prototype.onCompleted = function () {
if(!this.isStopped) {
this.isStopped = true;
this.o.onCompleted();
}
};
InnerObserver.prototype.dispose = function() { this.isStopped = true; };
InnerObserver.prototype.fail = function (e) {
if (!this.isStopped) {
this.isStopped = true;
this.observer.onError(e);
return true;
}
 
return false;
};
 
return IgnoreElementsObservable;
}(ObservableBase));
 
/**
* Ignores all elements in an observable sequence leaving only the termination messages.
* @returns {Observable} An empty observable sequence that signals termination, successful or exceptional, of the source sequence.
*/
observableProto.ignoreElements = function () {
return new IgnoreElementsObservable(this);
};