-
-
Save joepie91/3610c6e41bc654ccaadf to your computer and use it in GitHub Desktop.
Promisifying an EventEmitter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function scanForThing() { | |
return new Promise(function(resolve, reject){ | |
var emitter = scanLibrary.scan(); | |
emitter.on("discover", function(peripheral){ | |
resolve(peripheral); | |
}); | |
emitter.on("error", function(err){ | |
reject(err); | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment