Skip to content

NumberSignal does not have decrementBy API #21596

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

Open
abdullahtellioglu opened this issue Jun 3, 2025 · 4 comments
Open

NumberSignal does not have decrementBy API #21596

abdullahtellioglu opened this issue Jun 3, 2025 · 4 comments
Labels

Comments

@abdullahtellioglu
Copy link
Collaborator

Describe your motivation

NumberSignal has incrementBy API, which is very convenient in most cases. It would be nice to have decrementBy API, as well.

Describe the solution you'd like

Introduce decrementBy(double delta) that decreases the value by the delta amount

Describe alternatives you've considered

I used the increment API with negative numbers.

Additional context

Additionally, some utility method would be nice e.g. incrementByOne(), decrementByOne()

@Legioth
Copy link
Member

Legioth commented Jun 5, 2025

Why isn't incrementBy(-1) sufficient?

@abdullahtellioglu
Copy link
Collaborator Author

Debugging gets easier as you know which methods to track when looking for why the number is decreased.

It would make api symmetrical. It is the first method that you think of when you need to decrease a number.

@Legioth
Copy link
Member

Legioth commented Jun 5, 2025

It goes both ways. As long as incrementBy also accepts negative values, you would then have to look for invocations of either incrementBy or decrementBy to find the right place. (And I don't thinks we should make incrementBy reject negative values since that forces a completely pointless if (delta >= 0) incementBy(delta) else decrementBy(-delta) construct on cases that need to support both).

I would guess the main problem is discoverability, but it does so far seem that users do find the incrementBy(negativeValue) option relatively easily.

@abdullahtellioglu
Copy link
Collaborator Author

I am not saying that incrementBy should reject negative values, but rather there should be a decrementBy API that can even call the incrementBy method with a negated delta value.

I would guess the main problem is discoverability, but it does so far seem that users do find the incrementBy(negativeValue) option relatively easily.

Except me 😆 I even opened the NumberSignal class and looked for a method that does a subtraction operation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants