Skip to content

Enable to define different states #21

@busypeoples

Description

@busypeoples

Opening up this issue for discussion, maybe this could be interesting.
Enable to define different states and render them according to the current state.
Check this out example using Tasks f.e. https://codesandbox.io/s/vv92zqqz0l

const App = () => (
   <Fetch
        url="https://api.github.com/users/octocat"
        timeout={5000}
        >
         {({ result }) => (
           {result.cata(
             {
               notAsked: () => <div>Nothing Loaded</div>,
               loading: () => <div>Loading...</div>,
               error: error => <div>Something went wrong: {error}</div>,
               success: ({ users }) => (
                 <ul>{users.map(user => <UserComponent key={user.id} {...user} />)}</ul>
               )
            })
        )}
   </Fetch>
);

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions