-
Notifications
You must be signed in to change notification settings - Fork 4
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
How to limit the number of merge requests #6
Comments
Do you mean that if you set up one batcher and call Not sure I understand your requirements totally, but it might be out of the scope of the package. If you want to stagger the requesting a bit you might want to delay the fetching in your components as they render based on the index in your list. |
You could do something like this to stagger the batches, this approach should do one request pr 10 posts ish: const postFetcher = batshit.create({ ... });
const PostList = (props: {postIds: number[]}) => {
return (<>
{
props.postIds.map((postId, index) =>
<Post key={postId} postId={postId} index={index}/>
)
}
</>)
}
const Post = (props: {postId: number, index: number}) => {
const {data: post, isFetching} = useQuery(["post", props.postId], async () => {
await delay(index)
return postFetcher.fetch(props.postId)
});
return <div>
{
isFetching ?
<div>loading...</div>
: <h1>{post.title}</h1>
}
</div>
} |
@linhleedom Did you find a solution? |
I'm also up for a more elegant solution to limit number of "entityIds" that we submit in a single request. We have identified one example where we have 32.000 GUIDs in one api request (and the number is prone to grow further in the future). Could we add an option to batshit, so that one could define a max length of the id array, at which it fires off the api request, and start a new (10ms) timer? |
@yornaath looks good for me :) (In the mean time I found out that it's react-query that can't handle 32.000 ids, it simply crashes the browser, so a batch limit wont help here) |
@yornaath looks good to me. Can you publish the change to npm? I had to copy your logic code into the project and overwrite it. This should not be done. |
I want to limit the number of merge requests.
Ex: I want to get details of 100 posts, and in scheduler =10ms, batshit will batch about 20-30 requests into one request. But I want to In a batch, it only batches up to 8 requests at a time, instead of combining all requests within 10ms.
Then instead of having 1 request with 20 postIds, I will have 3 requests with
The text was updated successfully, but these errors were encountered: