https://github.com/hikire/wafflere
A (very) Simple Streams Library for ReasonML
https://github.com/hikire/wafflere
reasonml stream-library
Last synced: about 1 month ago
JSON representation
A (very) Simple Streams Library for ReasonML
- Host: GitHub
- URL: https://github.com/hikire/wafflere
- Owner: hikire
- License: mit
- Created: 2018-05-12T16:57:50.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-21T11:32:21.000Z (about 8 years ago)
- Last Synced: 2025-01-28T18:39:07.634Z (over 1 year ago)
- Topics: reasonml, stream-library
- Language: OCaml
- Homepage:
- Size: 47.9 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Waffle.re
Waffle is a simple streams library for reasonML, inspired by [flyd](https://github.com/paldepind/flyd), and was originally created for implementing [Meiosis](https://meiosis.js.org/) for state management - still haven't used it for that yet :innocent: .
Since Waffle is still under development, it lacks many of the features in flyd(e.g. combining streams, atomic updates, ...), so you're welcome to help :smile:
## Example:
```reason
let input = Waffle.stream();
let inc = Waffle.map(i => i + 1);
(inc |> Waffle.pipe) @@ input;
((i => Js.log(i)) |> Waffle.on) @@ inc; /* adding a listner */
input#pour(1); /* inc logs 2 */
Js.log(input#peek() == Some(1)); /* logs true */
(5 |> Waffle.pour) @@ inc; /* inc logs 6 */
let sum = Waffle.scanAndPipe((acc, v) => acc + v, 0, inc);
((i => Js.log(i)) |> Waffle.on) @@ sum; /* sum logs 6 (from inc + 0) */
Js.log("acc sum:");
(2 |> Waffle.pour) @@ sum; /* sum logs 8 */
(5 |> Waffle.pour) @@ sum; /* sum logs 13 */
```
## Installation
```sh
npm install --save reason-waffle
```
Then add `reason-waffle` to `bs-dependencies` in your `bsconfig.json`:
```js
{
...
"bs-dependencies": ["reason-waffle"]
}
```
## Usage with ReasonReact:
Please see [ReasonReactWaffle.re](https://github.com/ZuraJanaiNazayDa/reason-react-waffle).
## More... well, you know :sweat_smile: