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

Built In Support for Promise based source #2

Open
swashata opened this issue Apr 9, 2018 · 1 comment
Open

Built In Support for Promise based source #2

swashata opened this issue Apr 9, 2018 · 1 comment
Labels

Comments

@swashata
Copy link
Member

swashata commented Apr 9, 2018

The source of icons and search can be a promise which resolves to a valid JSON. We can accept that to have support for async source.

  1. Display a loading status on placeholder and dropdown while waiting for the promise to resolve.
  2. Once done, set the icons and search.
  3. Children components should be able to pick it up.

This also means some changes in the structure:

  1. Instead of relying on icons and search as props, we need to set state within FontIconPicker component.
  2. If it is not a promise, then simply init. Set internal state sourceStatus to "done".
  3. If it is a promise, then set state sourceInit to "waiting" and resolve the promise. When resolved, set sourceInit to "done". On error set sourceStatus to "error".
  4. Child component will pick it up from the state and will show appropriate message and UI.

API blob

const icons = fetch('https://gist.githubusercontent.com/swashata/c0db916b33700c91ab75f59d4aeba7d3/raw/366789b2d001a99f5f41f1ceab980d991de059c3/fontawesome-icons-with-categories.json')
    .then(data => data.json());

return <FontIconPicker icons={icons} />;
@swashata
Copy link
Member Author

Maybe with react suspense, it would be more feasible.

swashata pushed a commit that referenced this issue Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant