pl-fe: batch relationships requests
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
16
packages/pl-fe/src/api/batcher.ts
Normal file
16
packages/pl-fe/src/api/batcher.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { bufferScheduler, create, keyResolver } from '@yornaath/batshit';
|
||||
import memoize from 'lodash/memoize';
|
||||
|
||||
import type { PlApiClient } from 'pl-api';
|
||||
|
||||
const relationships = memoize((client: PlApiClient) => create({
|
||||
fetcher: (ids: string[]) => client.accounts.getRelationships(ids),
|
||||
resolver: keyResolver('id'),
|
||||
scheduler: bufferScheduler(200),
|
||||
}));
|
||||
|
||||
const batcher = {
|
||||
relationships,
|
||||
};
|
||||
|
||||
export { batcher };
|
||||
Reference in New Issue
Block a user