Pump-requests
Let's say we have an endpoint, which receives list of ids as a parameter to check their status (for example, list of favourites). However, we would like to call status of each item individually (think about React component, which will get all needed information for a component). This library does exactly one thing – it allows you to treat such requests as they were requests to check status of a single item. They are added into internal data structures, and each addition triggers debounced timer, so after defined time of silence it will invoke given function, passing list of all ids it collected.
;; // you can pass this function wherever you want// if you use redux, you can pass it to the// middlewareconst checkFavourite = ; ; // 'some'; // 'another'
API
; const checkFavourite = ;
There is nothing more! The idea for the library was born when I was struggling trying to prefetch different favourites in several places, and they clashed – I feel that treating them as independent single requests with single responsibility is a right way to go.
License
MIT