rrousselGit / state_notifier

ValueNotifier, but outside Flutter and with some extra perks
MIT License
311 stars 28 forks source link

Add the ability to set state in debug #76

Closed Amir-P closed 1 year ago

Amir-P commented 1 year ago

This PR adds debugState setter which changes state when in debug mode. This is essential when testing a StateNotifier and you want to provide a seed state. It becomes much easier to simulate different scenarios.

Also, isn't it better to annotate both debugState getter and setter with @visibleForTesting?

rrousselGit commented 1 year ago

An alternative might be to remove that debugState ... and instead mark state with its setter as @visibleForTesting instead of @protected

We're deprecate debugState for now to avoid a breaking change

Amir-P commented 1 year ago

We're deprecate debugState for now to avoid a breaking change

I can't see the deprecated annotation but that's better. I will change it.

codecov[bot] commented 1 year ago

Codecov Report

Merging #76 (cf81c6e) into master (7783bd3) will not change coverage. The diff coverage is n/a.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/rrousselGit/state_notifier/pull/76/graphs/tree.svg?width=650&height=150&src=pr&token=mmKICnJITW&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Remi+Rousselet)](https://app.codecov.io/gh/rrousselGit/state_notifier/pull/76?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Remi+Rousselet) ```diff @@ Coverage Diff @@ ## master #76 +/- ## ======================================= Coverage 85.40% 85.40% ======================================= Files 3 3 Lines 137 137 ======================================= Hits 117 117 Misses 20 20 ```
rrousselGit commented 1 year ago

While we're at it, I'll make this the v1.0.0 version. Enjoy :D

Amir-P commented 1 year ago

While we're at it, I'll make this the v1.0.0 version. Enjoy :D

If I knew it was going to be v1, I would suggest completely removing debugState instead of deprecating. Anyway, I'll try to update riverpod today.

rrousselGit commented 1 year ago

I've removed debugState on mt own :)

rrousselGit commented 1 year ago

I've already updated Riverpod too