Thanks for the awesome library. I was adding some typescript typings through the generics and noticed that it expects an array to be returned by the fetcher. In the README example (copied below for convenience) the user is an object with an id
and a name
and I am guessing the client.users.where(...)
function would return an array of those user objects [{id: 1, name: 'yornaath'}, {id: 2, name: 'TheSharpieOne'}]
. That is great
type User = { id: number; name: string };
const users = create<User, number>({
fetcher: async (ids) => {
return client.users.where({
id_in: ids,
});
},
resolver: keyResolver("id"),
scheduler: windowScheduler(10), // Default and can be omitted.
});
Perhaps the array can be added by the dev-user if they expect an array to be returned. Making the example above be const users = create<User[], number>({
That seems like a breaking type change, but it also seems better than having T[] | T
through the code since it's not as explicit.