PackRuble / cardoteka

The best type-safe wrapper over SharedPreferences. ⭐ Why so? -> strongly typed cards for access to storage -> don't think about type, use get|set -> can work with nullable values -> callback based updates
https://t.me/+AkGV73kZi_Q1YTMy
Apache License 2.0
2 stars 0 forks source link

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

Open PackRuble opened 3 months ago

PackRuble commented 3 months ago

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.