question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rename method Subscriptions.create for semantic clarity.

See original GitHub issue

The Subscriptions.create method is extremely useful but poorly named. Is there a reason that it does not have a more semantic name which emphasizes the nature of the action being for unsubscribe rather than on subscribe?

When you read code like this:

subscription.add(Subscriptions.create(() -> runnable.run()));

it is not at all apparent that this code is for unsubscription.

Something along the lines of unsubscribeAction, withUnsubscribeAction, or doOnUnsubscribe would add a ton of clarity to the readability of this code.

subscription.add(Subscriptions.unsubscribeAction(() -> runnable.run()));
subscription.add(Subscriptions.withUnsubscribeAction(() -> runnable.run()));
subscription.add(Subscriptions.doOnUnsubscribe(() -> runnable.run()));

Now I realize we can’t just rename this method, so I am proposing it as an addition along with deprecation of the original.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
JakeWhartoncommented, Jun 2, 2016

That changes nothing about the naming of the method and that it’s a poor choice.

On Wed, Jun 1, 2016, 10:15 PM Artem Zinnatullin notifications@github.com wrote:

Well, yeah. But after realizing that the only job of Subscription is to give an api to unsubscribe something and check if it’s already unsubscribed it becomes much more obvious.

interface Subscription { void unsubscribe(); boolean isUnsubscribed(); }

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ReactiveX/RxJava/issues/2967#issuecomment-223178104, or mute the thread https://github.com/notifications/unsubscribe/AAEEEXP94S4xf3_D7j6tjb0AdQInhR09ks5qHjzQgaJpZM4EhPDD .

0reactions
akarnokdcommented, Jun 28, 2016

I’m closing this issue due to inactivity. If you have further input on the issue, don’t hesitate to reopen this issue or post a new one. Better yet, you can propose a PR for 2.x about the name change if you wish.

Read more comments on GitHub >

github_iconTop Results From Across the Web

coding style - Naming: Should you sacrifice briefness for clarity?
If brevity can be sacrificed for clarity, it should. But if verbosity can be sacrificed for clarity, even better.
Read more >
Semantics in a Nutshell. It's a lack of clarity that creates… |
To summarise, semantics is about meaning. Good semantics equals clarity. And there are good reasons you should invest in it.
Read more >
A Semantic-Enabled Platform for Realizing an Interoperable ...
It leverages semantic web technologies to address the two key challenges in expanding the IoT beyond product silos into web-scale open ecosystems: data ......
Read more >
web3-core-subscriptions | Yarn - Package Manager
This subscriptions package is used within some web3.js packages. ... format is based on Keep a Changelog, and this project adheres to Semantic...
Read more >
Compose Foundation - Android Developers
RememberObserver is a replacement for CompositionLifecycleObserver with modified semantics and renamed methods. Changing to the new API can be done mechanically ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found