Skip to content

Instantly share code, notes, and snippets.

@MohammadAzimi
Created March 11, 2022 16:38
Show Gist options
  • Save MohammadAzimi/c6fec8816f50e779b551fd13e951c0f5 to your computer and use it in GitHub Desktop.
Save MohammadAzimi/c6fec8816f50e779b551fd13e951c0f5 to your computer and use it in GitHub Desktop.
example of converting callback function to promise
const popInitialNotificationPromise = () =>
new Promise((resolve, reject) => {
PushNotification.popInitialNotification((notification) => {
if (notification) {
resolve(notification);
} else {
resolve(undefined);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment