Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

@spoosh/plugin-deduplication

Request deduplication plugin for Spoosh - prevents duplicate in-flight requests.

Documentation · Requirements: TypeScript >= 5.0 · Peer Dependencies: @spoosh/core

Installation

npm install @spoosh/plugin-deduplication

Usage

import { Spoosh } from "@spoosh/core";
import { deduplicationPlugin } from "@spoosh/plugin-deduplication";

const spoosh = new Spoosh<ApiSchema, Error>("/api").use([
  deduplicationPlugin(),
]);

const spoosh = new Spoosh<ApiSchema, Error>("/api").use([
  deduplicationPlugin({ write: "in-flight" }),
]);

useRead((api) => api("posts").GET(), { dedupe: false });

Options

Plugin Config

Option Type Default Description
read "in-flight" | false "in-flight" Deduplication mode for reads
write "in-flight" | false false Deduplication mode for writes

Per-Request Options

Option Type Description
dedupe "in-flight" | false Override deduplication for this request

Modes

  • "in-flight" - Reuse existing in-flight request promise if one exists
  • false - Always make a new request