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

Observable.collect #4

Closed
experquisite opened this issue Aug 21, 2014 · 9 comments
Closed

Observable.collect #4

experquisite opened this issue Aug 21, 2014 · 9 comments
Assignees

Comments

@experquisite
Copy link

Similar to other Scala collections, it would be very helpful to have a collect(), taking the usual partial function, to simultaneously filter and map. An example use case is unwrapping one of several case classes with a single partial match and forwarding on the contents, useful for processing one message type out of several flowing on the observable.

@benjchristensen
Copy link
Member

cc @samuelgruetter @zsxwing

@zsxwing
Copy link
Member

zsxwing commented Aug 21, 2014

@experquisite do you mean the collect in the scala collection api?

def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[List[A], B, That]): That

I think it's helpful. Do you think the following API is what you want?

def collect[B](pf: PartialFunction[A, B]): Observable[B]

@zsxwing zsxwing self-assigned this Aug 21, 2014
@zsxwing
Copy link
Member

zsxwing commented Aug 21, 2014

I'll add it once the build script is set up.

@experquisite
Copy link
Author

Yes that would be most excellent. Thanks!

@headinthebox
Copy link
Contributor

Cool.

@samuelgruetter
Copy link
Collaborator

+1

There are actually quite a few methods on Scala collections which are not in RxJava, but would be useful in RxScala. We noticed this a long time ago already, but so far no one checked all Scala collection methods on whether they would be useful in RxJava. Quoting the outdated TODO list:

Add methods present in Scala collections library, but not in RxJava, e.g. aggregate à la Scala, collect, tails, ...

@benjchristensen
Copy link
Member

Go ahead and start working in this code base. This new repo will be for 0.21 and beyond. We can't release anything yet and don't have PR auto building right now, but dev can continue with PRs being tested on local dev machines.

@zsxwing
Copy link
Member

zsxwing commented Aug 22, 2014

collect is added in ReactiveX/RxJava#1623

@zsxwing
Copy link
Member

zsxwing commented Aug 31, 2014

Close as already added in ReactiveX/RxJava#1623

@zsxwing zsxwing closed this as completed Aug 31, 2014
zsxwing pushed a commit that referenced this issue May 31, 2015
Update the signature of flatMapWith and fix the Subject doc
zsxwing added a commit that referenced this issue Aug 31, 2015
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

5 participants