Skip to main content
Version: 5.x.x

Deduplication

In order to limit and optimize the number of queries to the backend, we can use the feature of deduplication. We enable it by setting the deduplicate: true field on the request options. Thanks to this setting, many requests made at the same time will be optimized to one request. We can refine the deduplication time with the deduplicateTime option in the request options.


Setup

export const getUsers = client.createRequest()({
endpoint: "/users",
deduplicate: true,
});

Example

The example is written in typescript, but it also works in React hooks.

// Multiple calls of the same request
getUsers.send();
getUsers.send();
getUsers.send();
getUsers.send();

// Only single request will be send to backend

To learn more of deduplication and alternative modes of requesting you can visit Dispatcher Docs.