Skip to content

hikire/WaffleRe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Waffle.re

Waffle is a simple streams library for reasonML, inspired by flyd, and was originally created for implementing Meiosis for state management - still haven't used it for that yet 😇 .

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 😄

Example:

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

npm install --save reason-waffle

Then add reason-waffle to bs-dependencies in your bsconfig.json:

{
  ...
  "bs-dependencies": ["reason-waffle"]
}

Usage with ReasonReact:

Please see ReasonReactWaffle.re.

More... well, you know 😅

About

A (very) Simple Streams Library for ReasonML

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages