JSPM

@thi.ng/rstream-graph

0.2.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1238
  • Score
    100M100P100Q87736F
  • License Apache-2.0

Declarative dataflow graph construction for @thi.ng/rstream

Package Exports

  • @thi.ng/rstream-graph

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@thi.ng/rstream-graph) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@thi.ng/rstream-graph

npm (scoped)

This project is part of the @thi.ng/umbrella monorepo.

About

Declarative, reactive dataflow graph construction using @thi.ng/rstream & @thi.ng/atom primitives.

Installation

yarn add @thi.ng/rstream-graph

Usage examples

import { Atom } from "@thi.ng/atom";
import * as rs from "@thi.ng/rstream";
import * as rsg from "@thi.ng/rstream-graph";

// (optional) state atom to source value change streams from
const state = new Atom({a: 1, b: 2});

// graph declaration / definition
const graph = rsg.initGraph(state, {
    // this node sources both of its inputs
    // from values in the state atom
    add: {
        fn: rsg.add,
        ins: [
            { path: "a" },
            { path: "b" }
        ],
    },
    // this node receives values from the `add` node
    // and the given iterable
    mul: {
        fn: rsg.mul,
        ins: [
            { stream: "add" },
            { stream: () => rs.fromIterable([10, 20, 30]) }
        ],
    }
});

// (optional) subscribe to individual nodes
graph.mul.subscribe({
    next: (x) => console.log("result:", x)
});

// result: 30
// result: 60
// result: 90

// changes in subscribed atom values flow through the graph
state.resetIn("a", 10);
// result: 360

Authors

  • Karsten Schmidt

License

© 2018 Karsten Schmidt // Apache Software License 2.0