General Question
In JavaScript, I have a pending Promise object and want to reject it, before it is resolved.
I could use deferred.reject()
, but it's marked as obsolete and seems to be an anti pattern.
So how to do it instead then? Are Promises the way to handle this at all?
More Specific
click1 = getPage1Promise();
// I want to reject click1 here, to avoid race conditions
click2 = getPage2Promise();
click1
.then(page1 => console.log('show page 1'))
.catch(err => console.log('dont show 1'))
click2
.then(page2 => console.log('show page 2'))
.catch(err => console.log('dont show 2'))
Aucun commentaire:
Enregistrer un commentaire