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

tryMap & flatMap operators #33

Closed
alcarvalho opened this issue Jun 10, 2015 · 8 comments
Closed

tryMap & flatMap operators #33

alcarvalho opened this issue Jun 10, 2015 · 8 comments

Comments

@alcarvalho
Copy link

ReactiveCocoa has an operator which is called tryMap is not the best name but I think we should have something similar on RxSwift.

On RxJava, the map itself is able to handle any runtime errors and just send an error event in case something throws inside the map operator. That would be the nicest way to have it. And maybe with Swift 2 will be able to.

But for now, how can we approach that?

Another operator that's really, really missing is a flatMap, don't you think?

I guess I could help with that, but I am creating this issue to discuss before.

@kzaher
Copy link
Member

kzaher commented Jun 10, 2015

Haha,
I have good sense for timing :)

flatMap will be ported in a few days, and it's in the process of porting.

For functions that can accept selector, there is usually *orDie overload that returns RxResult. This is documented little confusing right now in README.md. I'll fix that.

The orDie suffix was chosen as a explanation what will happen if function fails. Entire sink chain will be disposed. Maybe I should reconsider the wording in next 2.0 version.

So in case of map, you have mapOrDie (you can return success(value) or failure(error) from this one).

You have filter (that can never fail), and filterOrDie that can return error.

...

@alcarvalho
Copy link
Author

That's great news! 👍
And thank you for the explanation on the orDie operators. 😄

@kzaher
Copy link
Member

kzaher commented Jun 10, 2015

I usually learn where I've messed something when people are confused, so I'm solving one confusion at a time :)

Feel free to let me know if there are other pain points.

@kzaher
Copy link
Member

kzaher commented Jun 12, 2015

FYI, flatMap has entered develop branch, and he brought two friends with him :)

It will be released end week with other improvements.

@alcarvalho
Copy link
Author

Great, @kzaher! Thank you...

I was thinking about the OrDie functions. Maybe it would be clearer if they were called something like 'assertMap' as a prefix. Or even "mapOrError".

I have to confess I was afraid to use these "OrDie" functions at first because of their names, hahaha...

@kzaher
Copy link
Member

kzaher commented Jun 12, 2015

Then I'm glad they are working as designed and scare people :) That was my actual intention ;)

Maybe I should rename catch to resurrect :)))

@alcarvalho
Copy link
Author

That would be awesome! 😝

@kzaher
Copy link
Member

kzaher commented Jun 19, 2015

Hi,
so flatMap has entered the building :)
As for orDie suffix, I don't think it's ideal, but don't think it's horrible either :)

I think that your other suggestion you've made on Slack orFail could be maybe better then orDie, but I'll need to think about if and when to make those changes.

For now, I'll close this issue since flatMap is added to RxSwift, but you can open new one with orFail suggestion if you like.

@kzaher kzaher closed this as completed Jun 19, 2015
@debolee debolee mentioned this issue Jan 6, 2025
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants