Created
January 9, 2018 08:42
-
-
Save Zielak/bd71ad25d9cfefc6a07ee30e59ed425e to your computer and use it in GitHub Desktop.
breaking a long running Promise, because it runs too long.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var test = new Promise((resolve, reject) => { | |
var longReject; | |
var LONG = new Promise((resolve, reject) => { | |
longReject = reject; | |
setTimeout(() => resolve(), 5000) | |
}) | |
.then(() => console.log('LONG: resolved after 5 seconds')) | |
.catch(() => console.warn('LONG: rejected!')) | |
setTimeout(() => { | |
reject('running too long') | |
longReject(); | |
}, 2000) | |
}) | |
.then(() => console.log('test: resolved finally')) | |
.catch((reason) => console.warn('test: rejected! reason:', reason)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment