Skip to content

Instantly share code, notes, and snippets.

@Borvik
Borvik / network-get-debounce-poc.ts
Created July 18, 2024 10:44
POC: Leading cached network debounce
/*
This proof-of-concept is to demonstrate how someone might make debounced network requests
where _each_ request returns a value - rather than just the "bounced" calls getting ignored
Essential concept - while network request is in progress, more requests for the exact same
data are "attached" to the original request and all would then complete at the same time.
*/
// mockup of the real network get function (redis, http, db, etc...)
async function realGetData(key: string) {