Skip to content

Commit

Permalink
Add promises to readme (#71)
Browse files Browse the repository at this point in the history
* added handling promises to readme
  • Loading branch information
kkreine authored Sep 15, 2021
1 parent cb44017 commit b5c9604
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,19 @@ NodeJS.call("echo", ["’"], binary: true) # => {:ok, "’"}
```bash
mix test
```

### Handling Callbacks and Promises

You can see examples of using promises in the tests here:

https://github.com/revelrylabs/elixir-nodejs/blob/master/test/nodejs_test.exs#L125

and 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

0 comments on commit b5c9604

Please sign in to comment.