https://github.com/jaredly/reason_async
https://github.com/jaredly/reason_async
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/jaredly/reason_async
- Owner: jaredly
- Created: 2017-08-22T23:38:29.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-01-04T16:35:14.000Z (over 8 years ago)
- Last Synced: 2025-01-09T20:53:41.443Z (over 1 year ago)
- Language: OCaml
- Size: 2.31 MB
- Stars: 65
- Watchers: 4
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Async/await for Reason/OCaml!
[Clone the example repo](https://github.com/jaredly/reason_async_example) to get started quickly.
## Example usage
With promises
```
let doSomething = () => {
let module Let_syntax = Reason_async.Promise;
[%await let x = somethingPromisy
and y = anotherPromise];
/* ... */
[%awaitWrap let z = getFileContents()];
x + y + z
};
```
## Installation / setup
NOTE: You currently need to be using `bsb-native` in your project in order for weird bugs not to happen on recompilation. You'll want `"bs-platform": "git+https://github.com/bsansouci/bsb-native"` in your package.json.
- `yarn add reason_async` (or npm)
- add `reason_async` to your bs-dependencies in `bsconfig.json`
- add `reason_async` to your `ppx-flags` in `bsconfig.json`
Example `bsconfig.json`:
```json
{
"name": "myapp",
"refmt": 3,
"sources": "./src",
"bs-dependencies": ["reason_async"],
"ppx-flags": ["reason_async"]
}
```