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

add Observable.filterEval #760

Merged
merged 3 commits into from Nov 14, 2018

Conversation

Projects
None yet
3 participants
@yanns
Copy link
Contributor

commented Nov 1, 2018

Fix #758

self
.mapEval(a p(a).map((a, _)))
.filter(_._2)
.map(_._1)

This comment has been minimized.

Copy link
@alexandru

alexandru Nov 6, 2018

Member

You can replace filter and map with collect. It would be slightly more efficient.

filter(p).map(f) <-> collect { x if p(x) => f(x) }

This comment has been minimized.

Copy link
@Avasil

Avasil Nov 6, 2018

Collaborator

Alternatively, we could probably implement this "from scratch" as a new operator to do everything in one pass?

This comment has been minimized.

Copy link
@alexandru

alexandru Nov 6, 2018

Member

There no way we're going to do that, since it requires the logic of mapEval and mapEval is extremely complicated and that logic is already duplicated from flatMap.

This comment has been minimized.

Copy link
@yanns

yanns Nov 7, 2018

Author Contributor
* - ...
*/
final def filterEvalF[F[_]](p: A => F[Boolean])(implicit F: TaskLike[F]): Observable[A] =
filterEval(a => Task.from(p(a))(F))

This comment has been minimized.

Copy link
@alexandru

alexandru Nov 6, 2018

Member

This too needs a test.

This comment has been minimized.

Copy link
@yanns

yanns Nov 7, 2018

Author Contributor
@codecov

This comment has been minimized.

Copy link

commented Nov 6, 2018

Codecov Report

Merging #760 into master will increase coverage by 0.05%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #760      +/-   ##
==========================================
+ Coverage   90.36%   90.42%   +0.05%     
==========================================
  Files         415      419       +4     
  Lines       11774    11873      +99     
  Branches     2149     2185      +36     
==========================================
+ Hits        10640    10736      +96     
- Misses       1134     1137       +3

@alexandru alexandru merged commit 0dcab23 into monix:master Nov 14, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@yanns yanns deleted the yanns:758_observable_filterEval branch Nov 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.