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 materializeResults operator #679

Merged
merged 9 commits into from
Oct 5, 2018
Merged

Conversation

ra1028
Copy link
Contributor

@ra1028 ra1028 commented Oct 4, 2018

This operator is useful when we want to handle Result without to complete stream.
It has semantics similar to dematerialize.
And dematerializeResults which works in inverse is also added.

Use case:

// This stream doesn't complete even if an error sent.
viewModel.reactive.date.producer
    .take(duringLifetimeOf: self)
    .flatMap(.latest) { date in
        repository.getPrograms(on: date)
            .materializeResults()
    }
    .startWithValues { result in
        switch result {
        case .success(let programs)
            print(programs)

        case .failure(let error)
            print(error)
    }

Checklist

  • Updated CHANGELOG.md.

@ra1028 ra1028 changed the title Add matelializeResults operator Add materializeResults operator Oct 5, 2018
@mdiep
Copy link
Contributor

mdiep commented Oct 5, 2018

Awesome! 👍🏻

I've wanted this for a while, but I had a hard time deciding on a name. materializeResults and dematerializeResults seem like good choices.

@mdiep mdiep merged commit 0603876 into ReactiveCocoa:master Oct 5, 2018
@ra1028 ra1028 deleted the resultvalues branch October 6, 2018 02:44
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

Successfully merging this pull request may close these issues.

None yet

2 participants