-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
addition/proposalNew features or enhancementsNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interestMoving the issue forward requires implementers to express interest
Description
I really love Promise.resolve("some value")
, however if you want to delay this resolving you have to do something much uglier like
new Promise(resolve => setTimeout(() => resolve("some value"), 1000));
Would love a way to create a promise that waits and resolves. I made a proposal for Promise.after
to ES and was informed it is a better fit to recommend here.
It seems a global function might make more sense in this context. Maybe something like resolveIn(1000)
that would return a promise that resolves in 1000 milliseconds. This could even be implemented like so:
function resolveIn(milliseconds) {
return new Promise(resolve => setTimeout(() => resolve(milliseconds), milliseconds));
}
And could be used like:
resolveIn(1000).then(/* do something */);
And could be used to resolve a specified value after a delay like so:
resolveIn(1000).then(() => "some value").then(/* do something with "some value" */);
jimthedev, Ginden, cpatti97100, frigus02, kenrick95 and 9 more
Metadata
Metadata
Assignees
Labels
addition/proposalNew features or enhancementsNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interestMoving the issue forward requires implementers to express interest