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

Why no index or observable arguments in scan's accumulator? #1614

Closed
rickmed opened this issue Apr 13, 2016 · 6 comments
Closed

Why no index or observable arguments in scan's accumulator? #1614

rickmed opened this issue Apr 13, 2016 · 6 comments

Comments

@rickmed
Copy link

rickmed commented Apr 13, 2016

Sorry if this kind of question is out of place or out of format.

@kwonoj
Copy link
Member

kwonoj commented Apr 15, 2016

I don't recall why index is missing, but in general in RxJS 5 passing source observable is dropped by it doesn't have much use cases in general. It'd be appreciate if you can elaborate bit more if you'd like to have it, or else.

In case of index, it can be easily retrieved via accumulator of scan, something like

Rx.Observable.of('a','b','c','d').scan((acc, value) => {
  acc.idx++;
  acc.value = value;
  return acc;
}, { idx : -1, value: null }).subscribe(x => {
  console.log(`index: ${x.idx}, value: ${x.value}`);
});

(just wrote in a hurry only for pseudo purpose)

@rickmed
Copy link
Author

rickmed commented Apr 15, 2016

@kwonoj I ended up doing something like that in my case but it felt forced. I understand the drop of observable but all (most?) of the operators with selector functions have an index argument, no?

@kwonoj
Copy link
Member

kwonoj commented Apr 15, 2016

Most of operators requiring predicate passes its index, yes. Some of resultSelectors are not while. For this one I don't have exact answers though. /cc @Blesh

@staltz
Copy link
Member

staltz commented Apr 15, 2016

I believe we could add at least the index without any negative impact. Should be there IMO.

@kwonoj
Copy link
Member

kwonoj commented Apr 15, 2016

I agree it can be added, just curious if there was reason to not to.

kwonoj added a commit to kwonoj/rxjs that referenced this issue Apr 17, 2016
kwonoj added a commit to kwonoj/rxjs that referenced this issue Apr 18, 2016
@kwonoj kwonoj closed this as completed in a3ec896 Apr 23, 2016
@lock
Copy link

lock bot commented Jun 7, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants