HackerNoon Mobile

Better reading experience on the app
How to Convert a Javascript Callback to Promiseby@giwyni

How to Convert a Javascript Callback to Promise

tldt arrow
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

Most of the solutions available have you coding the callback inside the promise. The method described here takes the callback function and returns both a modified callback, along with a linked promise. This promise resolves when that modified callback is executed. This helps when a callback has to be passed to an external module. The code to implement the conversion of callbacks to promises becomes as simple as the function below.
featured image - How to Convert a Javascript Callback to Promise
vsvconsult@gmail.com HackerNoon profile picture

@giwyni

[email protected]

Receive Stories from @giwyni

react to story with heart

RELATED STORIES

L O A D I N G
. . . comments & more!