Skip to content

Instantly share code, notes, and snippets.

@nfriedly
Created September 30, 2019 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfriedly/907871227c132be28c195755eb150e86 to your computer and use it in GitHub Desktop.
Save nfriedly/907871227c132be28c195755eb150e86 to your computer and use it in GitHub Desktop.
function getData(callback) {
setTimeout(() => callback("hi"), 10);
}
function render(promiseData) {
promiseData.then(data => console.log("data"));
}
// wrapper around getData() to make it return a promise
function getDataPromise() {
return new Promise((resolve, reject) => {
getData(resolve);
});
}
// use render with the wrapper
render(getDataPromise());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment