Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

takeLast emits undefined it applied with no params #4851

Closed
kievsash opened this issue Jun 11, 2019 · 4 comments
Closed

takeLast emits undefined it applied with no params #4851

kievsash opened this issue Jun 11, 2019 · 4 comments

Comments

@kievsash
Copy link

Bug Report

Current Behavior
takeLast() operator when applied without any param returns undefined.

Reproduction
https://codepen.io/kievsash/pen/dEgyGX?editors=0010

let Rx = window.Rx = window['rxjs'];
let {forkJoin, Subject, merge, of} = Rx;
let {ajax} = Rx.ajax;
let {map, finalize, tap, takeLast, scan} = Rx.operators;
console.clear();


const m$ = ajax('https://jsonplaceholder.typicode.com/comments/1').pipe(takeLast()); // incorrect

//const m$ = ajax('https://jsonplaceholder.typicode.com/comments/1').pipe(takeLast(1)); // correct

m$.subscribe(console.warn)

Expected behavior
WEll, should be discussed I guess. I propose that takeLast() to work like takeLast(1) -

Environment

Possible Solution
To set count=1 by default here: https://github.com/ReactiveX/rxjs/blob/master/src/internal/operators/takeLast.ts#L50

Additional context/Screenshots

@kwonoj
Copy link
Member

kwonoj commented Jun 11, 2019

Since our interface strictly requires param, it's more like an edge case. If I were to amend behavior, I'd rather throw argumentRangeError as same as non-acceptable count param instead of implicitly fallback to other behavior.

@kievsash
Copy link
Author

Ok, If it is final decision I can try to provide pull request with expected behavior.

@kievsash
Copy link
Author

@cartant Kindly take a look: #4854

@kwonoj
Copy link
Member

kwonoj commented Jan 22, 2021

#5326

@kwonoj kwonoj closed this as completed Jan 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants