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

Checking and manipulating status #24

Open
ricokahler opened this issue Oct 11, 2019 · 0 comments
Open

Checking and manipulating status #24

ricokahler opened this issue Oct 11, 2019 · 0 comments
Labels
proposal This contains a proposal for a feature or fix. This work may be subject to be discarded.

Comments

@ricokahler
Copy link
Contributor

I have an issue with the naming of our helper functions isNormal, isLoading etc.

The prefix is is where I have the issue. The function isNormal does not check if the status is exactly normal, instead checks to see if that status contains normal.

So let's rename it? 🤔

isNormal => hasNormal

function Component() {
  const [data, status] = useFetch(myFetch):
  return <>
    {hasLoading(status) && <Spinner />}
    {hasNormal(status) && <>{data.stuff}</>}
  </>;
}

I think this helps communicate to our users that statuses are a collection of booleans vs a mutually exclusive state.


Manipulating a status (to force a certain status for the loader for example), currently requires some knowledge about bitwise operators which not great. Instead it would be better if we has manipulation methods like addNormal, removeNormal or similar.

Alternatively we could add a function addStatus(status, NORMAL) to reduce the API footprint.

@ricokahler ricokahler added the proposal This contains a proposal for a feature or fix. This work may be subject to be discarded. label Oct 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal This contains a proposal for a feature or fix. This work may be subject to be discarded.
Projects
None yet
Development

No branches or pull requests

1 participant