Open thom-nic opened 8 years ago
How about this for an interface:
const foo = debounce(fn, {hash: true})
Wherein {hash:true}
indicates that the arguments to fn
should be hashed to a string and a single promise returned for each unique hash value. Alternatively, you could provide your own hashing function:
const foo = debounce(fn, {hash: params => params.op + "=" + params.value})
If the hash
option is omitted, default functionality is retained.
I've got something similar to the README example, an XHR request that I want to debounce. However different components may want to use the same request with different query parameters, in which case both request should be allowed.
example:
I realize this complicates the design a bit but think it's a useful feature.