Add `after` option
fregante opened this issue · comments
Like sindresorhus/debounce-fn#9
Semi-related #10
Honestly I don't know how to reconcile this with Promises. I thought this was needed to match debounce-fn
but I can't make sense of return values of before:true, after: true
function calls.
// Default values
const debouncedFn = pDebounce(expensiveCall, 200, {before: false, after: true});
for (const i of [1, 2, 3]) {
debouncedFn(i).then(console.log);
}
//=> 3
//=> 3
//=> 3
// Current `leading: true`
const debouncedFn = pDebounce(expensiveCall, 200, {before: true, after: false});
for (const i of [1, 2, 3]) {
debouncedFn(i).then(console.log);
}
//=> 1
//=> 1
//=> 1
// This proposal
const debouncedFn = pDebounce(expensiveCall, 200, {before: true, after: true});
for (const i of [1, 2, 3]) {
debouncedFn(i).then(console.log);
}
//=> 1
//=> 1
//=> 1
// No changes?