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

Make the onRemove parameter in Watcher.attach mandatory? #14

Open
PackRuble opened this issue Mar 15, 2024 · 0 comments
Open

Make the onRemove parameter in Watcher.attach mandatory? #14

PackRuble opened this issue Mar 15, 2024 · 0 comments
Labels
discussion There's a lot to discuss

Comments

@PackRuble
Copy link
Owner

Users may forget to specify this parameter, resulting in incorrect program operation when the value is deleted from the storage. So if we make it a mandatory parameter, we can reduce the impact of such an error.

You can also make it a nullable type:

  V attach<V extends Object?>(
    Card<V> card,
    ValueCallback<V> callback, {
    required void Function()? onRemove,
    required Detacher detacher,
    bool fireImmediately = false,
  }) {

There is only one negative consequence - you will have to specify it as a parameter every time and fix all the past code. On each new use, specify null for this parameter when it is not needed.

@PackRuble PackRuble added the discussion There's a lot to discuss label Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion There's a lot to discuss
Projects
None yet
Development

No branches or pull requests

1 participant