Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Commit

Permalink
Closing Issue #541
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpodwysocki committed Feb 6, 2015
1 parent 8364c13 commit 55702b2
Show file tree
Hide file tree
Showing 30 changed files with 797 additions and 412 deletions.
2 changes: 2 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ var browsers = [{
'src/core/perf/operators/fromarray.js',
'src/core/linq/observable/generate.js',
'src/core/linq/observable/of.js',
'src/core/linq/observable/ofarraychanges.js',
'src/core/linq/observable/ofobjectchanges.js',
'src/core/linq/observable/never.js',
'src/core/linq/observable/pairs.js',
'src/core/linq/observable/range.js',
Expand Down
134 changes: 80 additions & 54 deletions dist/rx.all.compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -2386,6 +2386,10 @@
__super__.call(this, subscribe);
}

ObservableBase.prototype.subscribeCore = function(observer) {
throw new Error('Not implemeneted');
}

return ObservableBase;

}(Observable));
Expand Down Expand Up @@ -4431,36 +4435,39 @@

}(ObservableBase));

var MapObserver = (function (__super__) {
inherits(MapObserver, __super__);
function MapObserver(observer, selector, source) {
this.observer = observer;
this.selector = selector;
this.source = source;
this.index = 0;
this.isStopped = false;
}

function MapObserver(observer, selector, source) {
this.observer = observer;
this.selector = selector;
this.source = source;
this.index = 0;
__super__.call(this);
MapObserver.prototype.onNext = function(x) {
if (this.isStopped) { return; }
try {
var result = this.selector(x, this.index++, this.source);
} catch(e) {
return this.observer.onError(e);
}

MapObserver.prototype.next = function(x) {
try {
var result = this.selector(x, this.index++, this.source);
} catch(e) {
return this.observer.onError(e);
}
this.observer.onNext(result);
};

MapObserver.prototype.error = function (e) {
this.observer.onNext(result);
};
MapObserver.prototype.onError = function (e) {
if(!this.isStopped) { this.isStopped = true; this.observer.onError(e); }
};
MapObserver.prototype.onCompleted = function () {
if(!this.isStopped) { this.isStopped = true; this.observer.onCompleted(); }
};
MapObserver.prototype.dispose = function() { this.isStopped = true; };
MapObserver.prototype.fail = function (e) {
if (!this.isStopped) {
this.isStopped = true;
this.observer.onError(e);
};

MapObserver.prototype.completed = function () {
this.observer.onCompleted();
};
return true;
}

return MapObserver;
}(AbstractObserver));
return false;
};

/**
* Projects each element of an observable sequence into a new form by incorporating the element's index.
Expand All @@ -4476,12 +4483,26 @@
};

/**
* Retrieves the value of a specified property from all elements in the Observable sequence.
* @param {String} prop The property to pluck.
* Retrieves the value of a specified nested property from all elements in
* the Observable sequence.
* @param {Arguments} arguments The nested properties to pluck.
* @returns {Observable} Returns a new Observable sequence of property values.
*/
observableProto.pluck = function (prop) {
return this.map(function (x) { return x[prop]; });
observableProto.pluck = function () {
var args = arguments, len = arguments.length;
if (len === 0) { throw new Error('List of properties cannot be empty.'); }
return this.map(function (x) {
var currentProp = x;
for (var i = 0; i < len; i++) {
var p = currentProp[args[i]];
if (typeof p !== 'undefined') {
currentProp = p;
} else {
return undefined;
}
}
return currentProp;
});
};

function flatMap(source, selector, thisArg) {
Expand Down Expand Up @@ -4719,36 +4740,41 @@

}(ObservableBase));

var FilterObserver = (function (__super__) {
inherits(FilterObserver, __super__);
function FilterObserver(observer, predicate, source) {
this.observer = observer;
this.predicate = predicate;
this.source = source;
this.index = 0;
this.isStopped = false;
}

function FilterObserver(observer, predicate, source) {
this.observer = observer;
this.predicate = predicate;
this.source = source;
this.index = 0;
__super__.call(this);
FilterObserver.prototype.onNext = function(x) {
try {
var shouldYield = this.predicate(x, this.index++, this.source);
} catch(e) {
return this.observer.onError(e);
}
shouldYield && this.observer.onNext(x);
};

FilterObserver.prototype.next = function(x) {
try {
var shouldYield = this.predicate(x, this.index++, this.source);
} catch(e) {
return this.observer.onError(e);
}
shouldYield && this.observer.onNext(x);
};

FilterObserver.prototype.error = function (e) {
FilterObserver.prototype.onError = function (e) {
if(!this.isStopped) { this.isStopped = true; this.observer.onError(e); }
};
FilterObserver.prototype.onCompleted = function () {
if(!this.isStopped) { this.isStopped = true; this.observer.onCompleted(); }
};
FilterObserver.prototype.dispose = function() { this.isStopped = true; };
FilterObserver.prototype.fail = function (e) {
if (!this.isStopped) {
this.isStopped = true;
this.observer.onError(e);
};
return true;
}

return false;
};

FilterObserver.prototype.completed = function () {
this.observer.onCompleted();
};

return FilterObserver;
}(AbstractObserver));

/**
* Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
Expand Down
2 changes: 1 addition & 1 deletion dist/rx.all.compat.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/rx.all.compat.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 55702b2

Please sign in to comment.