How async works in a Promise implementation

const delay = milliseconds => new Nancy(resolve => setTimeout(resolve, milliseconds));
const afterPromise = delay(500).then(() => console.log('done'));
const callLater = getMember => callback => new Nancy(resolve => laterCalls.push(() => resolve(getMember()(callback))));
for (const laterCall of laterCalls) {
laterCall();
}

--

--

--

Keyvan is co-founder and CEO at Functionland, an open-source startup working on the intersection of Blockchain and AI

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Keyvan M. Sadeghi

Keyvan M. Sadeghi

Keyvan is co-founder and CEO at Functionland, an open-source startup working on the intersection of Blockchain and AI

More from Medium

How to use React Context

Redux Toolkit — The cheat sheet for Redux development

Testing useDebouncedValue hooks

Square Payments with React, Typescript, and Netlify Functions