[RFC] feat: Use a status
enum to label the current stage of a SWR hook
#1215
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
I've been using this library, and I've collected some feedback from colleagues or people I show this hook to.
One persistent subject is that, often developers want to derive the
status
of the hook, that is, is it loading? is it validating? is there a difference between them at all? is there any data, etc. Refer to: #563I understand that we should open up discussions for these subjects first, but in this case it seemed best to talk over the code, because of the change itself and because I am short on bandwidth as of now.
I'll create a discussion thread and link both. Hopefully it doesn't create confusion. #1217
At the core of this PR, we derive a new key called
status
which can beloading
,stale
,error
orvalidating
.In addition, I noticed that
isValidating
doesn't really settle on error cases. This might introduce breaking changes for users.I included some tests which helpfully help understanding the subject matter of the feature.
Last but not least, more documentation is needed.