Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

useLoadsCache should be a typed response #32

Open
dwjohnston opened this issue Sep 12, 2019 · 0 comments
Open

useLoadsCache should be a typed response #32

dwjohnston opened this issue Sep 12, 2019 · 0 comments

Comments

@dwjohnston
Copy link

Similar to other issues.

if I do

Somewhere:


export async function fetchUser() : Promise<User> {
    return new Promise((res, rej) => {
        setTimeout(() => {
            res({
                userId: 101
            }); 
        }, 1000)
    }); 
}
    const loadUser = useCallback(fetchUser, []); 

...

   const { response: userResponse, isPending: userIsPending,  } = useLoads(loadUser, {
        context: 'user'
    });

Elsewhere

const user = useLoadsCache('user'); 

The signature should be the same as the the function I pased to useLoads, ie User | undefined.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant