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

New rule for detecting if an emitter is disposed before emitting #7

Open
juliocbcotta opened this issue Feb 24, 2021 · 1 comment
Open

Comments

@juliocbcotta
Copy link

Hey, would it be possible to have a new rule that checks if emitter.isDIsposed() is called before publishing an update?
For cases like below:

Maybe.create((MaybeOnSubscribe<LatLng>) emitter -> {
               LatLng coordinates = null;
               try {
                   coordinates = computeCoordinates();
                  if (!emitter.isDisposed()) {
                        if (coordinates != null) {
                            emitter.onSuccess(coordinates);
                        } else {
                            emitter.onComplete();
                        }
                    }
                  } catch (final Exception e) {
                    if (!emitter.isDisposed()) {
                         emitter.onError(e);
                    }
            }

It seems that without the check we can get non deliverable exceptions.
Thanks

@hvisser
Copy link
Contributor

hvisser commented Feb 24, 2021

Should be possible for sure, though as always it could be a bit tricky to check. I'm open to contributions if anyone wants to give this a try.

@hvisser hvisser changed the title New rule New rule for detecting if an emitter is disposed before emitting Feb 24, 2021
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