Skip to content

Commit

Permalink
fix(last): emit value matches with predicate instead of result of pre…
Browse files Browse the repository at this point in the history
…dicate
  • Loading branch information
kwonoj authored and benlesh committed Sep 16, 2015
1 parent 93a5bd9 commit 0f635ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions spec/operators/last-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
2 changes: 1 addition & 1 deletion src/operators/last.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class LastSubscriber<T> extends Subscriber<T> {
if(result === errorObject) {
this.destination.error(result.e);
} else if (result) {
this.lastValue = result;
this.lastValue = value;
this.hasValue = true;
}
} else {
Expand Down

0 comments on commit 0f635ee

Please sign in to comment.