Comments (4)
You are handling it fine. The caller is notified with the 'canceled' string. If it becomes a bit superfluous when it throws, you can make a string comparison in the catch
clause and simply ignore the case with a noop.
from debounce-async.
I have a use case where I don't want to handle errors with catch()
so I'd love an argument to allow me to disable this feature. I'd like to be able to essentially force shouldCancel
to always be false.
from debounce-async.
It rejects in order to tell which are ignored, and to notify the caller. If it resolves with nothing for the ignored, the caller needs to make a comparison between the resolved values in order to tell which is ignored and which is not. It becomes trickier.
from debounce-async.
Okay, I think that makes sense, maybe I'm just handling it incorrectly. Here's my situation:
const debouncedAjax = debounce((params) => {
return $.ajax('/api/items', params);
});
// else where in code
// function called whenever params change...this is debounced so if multiple params change quickly
// we don't call the ajax function each time
const result = debouncedAjax(params);
result.then(() => { alert('success!'); })
.catch(e => { alert(e.message); }); // alerts "cancelled" every time....how do I prevent this?
from debounce-async.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from debounce-async.