0.11.1 • Published 2 years ago

agos v0.11.1

Weekly downloads
3
License
MIT
Repository
github
Last release
2 years ago

Agos

JavaScript utility for data flow composition.

Overview

Agos (Filipino translation of Stream) is a utility library that helps the data flow to be composed in a functional manner. It is inspired by other reactive libraries like RxJS, xstream and mostjs but with one key difference, the data source is naturally interactive. The general idea of the library is base on the article Redefining Observarble, basically, it enables the data source to be reactive with an outside entity like an observer. It is also implements Fantasy Land Semigroup, Monoid, Functor, Apply, Applicative, Chain, Monad and has interoperability in Observable.

Installation

Install it using npm or yarn.

npm install agos

Example

import Stream, { pipe, create, filter, listen } from "agos";

// create main source
const interval = create((open, next, fail, done, talkback) => {
  let count = 0;
  // propagate data
  const id = setInterval(() => next(++count), 100);

  // talkback is another stream that comes
  // from the outside this enable the main
  // source to be reactive on cancellation
  // or anything depending on the implementaion,
  // see that this piped stream filters only data
  // that pertains to Stream cancellation stopping
  // the data propagation
  pipe(
    talkback,
    filter(data => data === Stream.CANCEL),
    listen(() => {
      clearInterval(id);
      done(true)
    })
  )
  open();
});

// create cancel source
const cancel = create((open, next, fail, done) => {
  open();
  setTimeout(() => {
    // propagates CANCEL
    next(Stream.CANCEL);
    done(false);
  }, 500);
});

// listen to main source and 
// passing the cancel source to
// listen function
pipe(
  interval,
  listen({
    open: () => console.log("open"),
    next: value => console.log(value),
    fail: error => console.log(error),
    done: cancelled => console.log("done", "cancelled", cancelled),
  }, cancel)
);

// logs
// open
// 1
// 2
// 3
// 4
// done cancelled true

License

This project is licensed under the MIT License - see the LICENSE file for details.

switch back to never as default talkback source

multicast bug where all listenerrs are cancelled even only one cancel signal has been propagated

0.11.1

2 years ago

0.11.0

3 years ago

0.10.3

3 years ago

0.10.1

3 years ago

0.10.2

3 years ago

0.10.0

3 years ago

0.9.0

3 years ago

0.8.1

3 years ago

0.8.0

3 years ago

0.9.2

3 years ago

0.9.1

3 years ago

0.8.2

3 years ago

0.7.0

3 years ago

0.6.0-alpha.1

4 years ago

0.6.0

4 years ago

0.6.0-alpha

4 years ago

0.5.0-alpha.3

4 years ago

0.5.0-alpha.2

4 years ago

0.5.0-alpha.1

4 years ago

0.5.0-alpha

4 years ago

0.4.0-alpha.3

4 years ago

0.4.0-alpha.2

4 years ago

0.4.0-alpha.1

4 years ago

0.3.0-alpha.2

4 years ago

0.3.0-alpha.1

4 years ago

0.3.0-alpha

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.0

5 years ago

0.0.0

5 years ago