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

Name of method ignoreErrors break contract of PublishSubject #217

Open
ajjnix opened this issue Jun 6, 2019 · 1 comment
Open

Name of method ignoreErrors break contract of PublishSubject #217

ajjnix opened this issue Jun 6, 2019 · 1 comment

Comments

@ajjnix
Copy link

ajjnix commented Jun 6, 2019

PublishSubject is not working with ignoreErrors function because ignoreErrors is synonym of retry. But PublishSubject can't retry by contract cause it's not operation.

        let subject = PublishSubject<Int>()
        _ = subject.ignoreErrors().subscribe(onNext: {
            print($0)
        })
        subject.onNext(1)
        subject.onError(RxError.unknown)
        subject.onNext(2)
        subject.onNext(3)

// output: INFINIRY_LOOP

In this code I can think the sequence can't terminated on error (and yes it's not terminated 😺) but it's not right by contract of Observable. So I think this operator is mislead and I suggest to remove it.

@freak4pc
Copy link
Member

freak4pc commented Jun 6, 2019

You can't technically do anything against the contract.

The stream isn't terminated because ignoreErrors is just an alias to retry - by infinitely retrying the error'd stream, you are stuck in an infinite loop.

What we can do is change the documentation perhaps. I also think the naming is a bit misleading, because you're not exactly ignoring errors. Ignoring errors would be something like materialize, filtering errors and dematerialize.

@fpillet your thoughts?

@ajjnix ajjnix changed the title Name method ignoreErrors break contract of PublishSubject Name of method ignoreErrors break contract of PublishSubject Jun 6, 2019
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

2 participants