Friday, January 28, 2022

Eager & lazy Promise

Promises are always eager to the execution process. It means that when a Promise is created, the callback is immediately executed. That is ok, but sometimes you need call Promise in specific time, for example after setting some resources. 

The sollution is to wrap a Promise in a function.

Lets look an example:

Happy codding.

No comments:

Post a Comment