Handling asynchronous scenarios in a Promise implementation can be mind-blowing. Not so much if you embrace the functional programming paradigm. Though guess I fell short of properly explaining how it works exactly in Nancy, evident by the questions I received via direct messages and comments on social media. I try to explain a bit more here, assuming you commanded the Nancy article.
To refresh our memory, here is the final code:
In acync scenarios,
reject are not called immediately. In our example:
const delay = milliseconds => new Nancy(resolve => setTimeout(resolve, milliseconds));
resolve will be called after
First thing that you notice is that a Promise has three states, so should…