diff --git a/spec/operators/last-spec.js b/spec/operators/last-spec.js index e6f80b7cb3..f28c787b61 100644 --- a/spec/operators/last-spec.js +++ b/spec/operators/last-spec.js @@ -19,4 +19,15 @@ describe('Observable.prototype.last()', function(){ var expected = '----'; expectObservable(e2.last()).toBe(expected); }); + + it('Should return last element matches with predicate', function() { + var e1 = hot('--a--b--a--b--|'); + var expected = '--------------(b|)'; + + var predicate = function (value) { + return value === 'b'; + } + + expectObservable(e1.last(predicate)).toBe(expected); + }); }); \ No newline at end of file diff --git a/src/operators/last.ts b/src/operators/last.ts index 89e6b1b897..51282c9047 100644 --- a/src/operators/last.ts +++ b/src/operators/last.ts @@ -47,7 +47,7 @@ class LastSubscriber extends Subscriber { if(result === errorObject) { this.destination.error(result.e); } else if (result) { - this.lastValue = result; + this.lastValue = value; this.hasValue = true; } } else {