All Projects → lilactown → bs-most

lilactown / bs-most

Licence: other
Reason/BuckleScript bindings for the Most.js reactive toolkit

Programming Languages

ocaml
1615 projects

Projects that are alternatives of or similar to bs-most

Redux Most
Most.js based middleware for Redux. Handle async actions with monadic streams & reactive programming.
Stars: ✭ 137 (+234.15%)
Mutual labels:  reactive, reactive-programming, streams
ureact
Minimalistic reactive library for c++
Stars: ✭ 122 (+197.56%)
Mutual labels:  reactive, reactive-programming
reacted
Actor based reactive java framework for microservices in local and distributed environment
Stars: ✭ 17 (-58.54%)
Mutual labels:  reactive, reactive-programming
assembler
Functional, type-safe, stateless reactive Java API for efficient implementation of the API Composition Pattern for querying/merging data from multiple datasources/services, with a specific focus on solving the N + 1 query problem
Stars: ✭ 102 (+148.78%)
Mutual labels:  reactive, reactive-programming
sample-spring-reactive
sample reactive microservices using spring 5, spring boot, spring webflux and project reactor
Stars: ✭ 26 (-36.59%)
Mutual labels:  reactive, reactive-programming
springboot-rsocketjwt-example
Example of using JWT with RSocket and Spring Boot
Stars: ✭ 26 (-36.59%)
Mutual labels:  reactive, reactive-programming
Rx.Http
A reactive way to make HTTP Request in .NET Core 🚀
Stars: ✭ 62 (+51.22%)
Mutual labels:  reactive, reactive-programming
ng-observe
Angular reactivity streamlined...
Stars: ✭ 65 (+58.54%)
Mutual labels:  reactive-programming, streams
purescript-pop
😃 A functional reactive programming (FRP) demo created with PureScript events and behaviors.
Stars: ✭ 33 (-19.51%)
Mutual labels:  reactive, reactive-programming
whatsup
Reactive framework, simple, fast, easy to use!
Stars: ✭ 115 (+180.49%)
Mutual labels:  reactive, streams
fpEs
Functional Programming for EcmaScript(Javascript)
Stars: ✭ 40 (-2.44%)
Mutual labels:  reactive, reactive-programming
servable
"simple" observable implementation based off RxJS & kefir Docs
Stars: ✭ 14 (-65.85%)
Mutual labels:  reactive, reactive-programming
realar
5 kB Advanced state manager for React
Stars: ✭ 41 (+0%)
Mutual labels:  reactive, reactive-programming
KotlinReactiveMS
An educational project to learn reactive programming with Spring 5 and Kotlin
Stars: ✭ 33 (-19.51%)
Mutual labels:  reactive, reactive-programming
netifi-quickstart-java
Project to assist you in getting started using Netifi.
Stars: ✭ 23 (-43.9%)
Mutual labels:  reactive, reactive-programming
Akka
Examples and explanations of how Akka toolkit works
Stars: ✭ 20 (-51.22%)
Mutual labels:  reactive, reactive-programming
reason-rt-binding-generator
Reason binding generator for react-toolbox
Stars: ✭ 18 (-56.1%)
Mutual labels:  reasonml, bucklescript-bindings
Smallrye Mutiny
An Intuitive Event-Driven Reactive Programming Library for Java
Stars: ✭ 231 (+463.41%)
Mutual labels:  reactive, streams
bs-rsuite-ui-react
Reason bindings for React Suite UI library
Stars: ✭ 26 (-36.59%)
Mutual labels:  reasonml, bucklescript-bindings
SwiftObserver
Elegant Reactive Primitives for Clean Swift Architecture #NoRx
Stars: ✭ 14 (-65.85%)
Mutual labels:  reactive, reactive-programming

bs-most

BuckleScript bindings for Most.js.

In Reason:

let add = (x, y) => x + y;

let isEven = x => x mod 2 === 0;

Most.(
  fromList([0, 1, 2, 3, 4, 5, 6, 7, 8])
  |> map(add(2))
  |> filter(isEven)
  |> observe(x => Js.log(x))
  |> Js.Promise.then_((_) => {
       Js.log("Stream completed");
       Js.Promise.resolve();
     })
);


/**
 * Logs:
 * 2
 * 4
 * 6
 * 8
 * 10
 * Stream completed
 **/

An example of implementing the Redux architecture in a ReasonReact project can be seen here.

How do I install it?

Inside of a BuckleScript project:

npm install --save bs-most

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

{
  ...
  "bs-dependencies": [
    "bs-most"
  ]
}

How do I use it?

The Most.js API docs are probably the best source of information about each method. This library attempts to provide very low-level bindings, except for what's noted in the What's different section.

The bindings are a single file in src/most.re. I try to provide comments next to each binding and am working on flushing out tests so that users can refer to them.

I am also available by e-mail or DM on the Reason discord (username: @lilactown).

What's missing

  1. generate - Reason doesn't have generator support yet
  2. transduce - Awkward to use in Reason/OCaml without a solid transducer impl (maybe coming soon?? 😉)
  3. combineArray - the callback for this is variadic (depending on how many streams you have in the array), not sure how to type it yet 😞

What's different

  1. Predicates that normally return "truthy" values, now only accept returning booleans
  2. sample is variadic so we offer sample1, sample2, sample3... sample6
  3. fromEvent - DOM events are supported, but generic EventEmitter's are not yet
  4. from only works on arrays right now; generic iterators must be coerced
  5. fromList is a function that creates a stream from a Reason List type, e.g. fromList([1, 2, 3])
  6. unfold is modeled a bit differently - instead of taking in a JS object { done, value, seed }, it takes an option (value, seed). Example:
/* emits 2,4,6 then completes */
Most.unfold(
  (seed) =>
    if (seed < 4) {
      let nextSeed = seed + 1;
      Some((seed * 2, nextSeed));
    } else {
      None;
    },
  1
);

Subjects

This library also includes some bindings for Subjects. Subjects are very useful for e.g. implementing a state store/dispatch system. The API is a little bit different from the raw most-subject library:

  • Subject.make: creates an asynchronous Subject
  • Subject.asStream: casts a subject to a stream, to be used by the rest of the Most module
  • Subject.next: emits a value on a subject
  • Subject.error: emits an error on a subject
  • Subject.complete: completes a subject with no value
  • Subject.completeWith: completes a subject with a value

Build

npm run build

Build + Watch

npm run watch

Testing

npm run test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].