-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling callbacks and promises #61
Comments
You can see examples of using promises in the tests here: https://github.com/revelrylabs/elixir-nodejs/blob/master/test/nodejs_test.exs#L125 from the javascript code here: module.exports = async function echo(x, delay = 1000) {
return new Promise((resolve) => setTimeout(() => resolve(x), delay))
} https://github.com/revelrylabs/elixir-nodejs/blob/master/test/js/slow-async-echo.js A PR to add this example in the |
@kicktheken I didn't see this in the readme, so I just did a PR to add this. |
That explains promises, but what about actual callbacks. For example: module.exports = function echo(x, cb) {
setTimeout(() => cb(null, x), 2000)
} I think the only way to interact with code like that ☝️ is to actually wrap it with a promise. We cannot supply callbacks to the Any advise on handling rejected promises? So far I can't get the elixir code to read the response. |
Hey,
How does elixir-nodejs handle function callbacks and promises? I couldn't find those topics on docs.
Cheers,
Gustavo
The text was updated successfully, but these errors were encountered: