Skip to content

Repository files navigation

Basic event streams for OCaml(BuckleScript)

Build Status

Inspired by - Basic event streams for javascript

Introduction

OOP programming consider a stream as an object. On the other hand, in functional programming a stream is a higher order function.

OOP (zen-observable)

constunsubscribe=Observable.of(1,2,3).map(x=>x+1).filter(x=>x%2!==0).subscribe({next: value=>console.log(value),error: err=>console.error(err),done: ()=>console.log('done')});

FP

let unsubscribe = [1; 2; 3]
|>Stream.Async.of_list ~delay:1000|>Stream.map (funx -> x +1)
|>Stream.filter (funx -> x mod2<>0)
|>Stream.subscribe (funx -> x |> string_of_int |> print_endline)

API

module Stream


Setup

Node.js

git clone https://github.com/mapogolions/streams.git
cd streams
npm install
npm run build
npm run test
node src/app.bs.js

Browser

git clone https://github.com/mapogolions/streams.git
cd streams
npm install
npm run build
npm run test
npm run webpack

then open ./public/index.html (no server needed!)

Clean up folder

npm run clean

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages