Status indicator
See original GitHub issueI think the result should have a field indicating the status of the query. It could be a simple boolean flag loading
or a more sophisticated status
enum (to indicate revalidation, etc.).
Checking data
for truthiness does not cut it if you consider that the data returned from the fetcher could in theory be null
(or even undefined
).
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:9 (6 by maintainers)
Top Results From Across the Web
OPPS Payment Status Indicators - JE Part A - Noridian Medicare
Indicator Item/Code/Service OPPS Payment Status
M Items and services not billable to the FI or MAC Not paid under OPPS .
P Partial hospitalization service...
Read more >Proposed Payment Status Indicators Indicator Item/Code ...
Indicator. Item/Code/Service. OPPS Payment Status. Services furnished to a hospital outpatient that are paid under a fee schedule or.
Read more >Revenue Center Status Indicator Code - ResDAC
The revenue center status indicator code is most useful with outpatient hospital claims, where multiple methods may be used to determine the payment...
Read more >Status indicator Definition | Law Insider
Status indicator or “SI” means a payment indicator that identifies whether a service represented by a CPT or HCPCS code is payable under...
Read more >Status indicators - IBM
A status indicator is a color bar that displays performance data, making it possible for you to quickly view the status of your...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for sharing @darrenjennings! I’ll also add my 2 cents.
I love the idea, but enum is a bit annoying to me. What do you think about this proposal:
The good thing is that users don’t need to import all the enums, and the editor will autocomplete.
The only concern for this status indicator idea is, since we are building these “high-level” states, their names have to be very clear and have to be complete.
Complete means that we have a group of 3 base values (data, error, isValidating) and all of them have 2 states, the derived states will be 2^3 = 8 different possibilities. It grows exponentially:
These are a lot and I believe there is at least one use case for each state. So I preferred to leave it to the users to determine which states their app needs. But after all I can see the benefit of directly returning the ready-to-use app state to the user.
@shuding I like the naming of all 8 states! Even though it seems like it could grow exponentially, it does limit the guesswork on how many states your swr-dependent ui can devolve into*. Though we had some discussion here around the ambiguity of the state names e.g. “what is ‘error’?”. I think it can mostly be explained to say a swr state
error
is “fetcher threw”. If you don’t want to throw (e.g. 404 == user is logged out), then you can catch in your fetcher.It would be my preference to define them as string literals so that you can do simple equality checks that can be used with useReducer or switch statements without having to check multiple
state.*
flags. This gives you editor autocomplete as well. It is more of a state machine way to do it.* and maybe it is overblown to think there is another property that would be introduced, maybe cancelled? I never cancel requests so open to if you think there would be a new state that would give it 16 states.