Skip to content

docs: Fix syntax of batshit in batching-requests article #9269

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

Open
wants to merge 1 commit into
base: v4
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ The problem is that orchestrating a single fetch for all rendered user details c
First lets setup a batcher using [@yornaath/batshit](https://www.npmjs.com/package/@yornaath/batshit)

```ts
import { Batcher, windowScheduler, keyResolver } from "@yornaath/batshit"
import { create, windowScheduler, keyResolver } from "@yornaath/batshit"

type User = { id: number, name: string }

const users = Batcher<User, number>({
const users = create<User[], number>({
// The fetcher resolves the list of queries(here just a list of user ids as number) to one single api call.
fetcher: async (ids: number[]) => {
return api.users.where({
Expand Down Expand Up @@ -72,4 +72,4 @@ const UserDetails = (props: {userId: number}) => {
### batshit docs

For more information about how to create batchers with custom resolving and request scheduling please refer to the batshit repo readme
over at the [yornaath/batshit github repository](https://github.com/yornaath/batshit/)
over at the [yornaath/batshit github repository](https://github.com/yornaath/batshit/)