• This repository has been archived on 27/Jun/2023
  • Stars
    star
    128
  • Rank 279,240 (Top 6 %)
  • Language
    JavaScript
  • License
    Creative Commons ...
  • Created over 7 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

React Components for visualising RxJS observables and operators

RxJS Diagrams

React Components for visualising RxJS observables and operators

RxJS Diagrams provides React Components for interactively visualising RxJS observables and operators. It is a rewrite (and redesign) of the amazing RxMarbles. The goal is to provide simple and reusable components for quickly explaining how RxJS works.

npm install --save rxjs-diagrams

Don't forget to install its peer dependencies, react and rxjs.

Usage

One input stream

This renders an SVG showing the input values and the result. The input values are converted to an observables and then transformed to an output using the transform prop.

import 'rxjs' // This imports all observables, operators, etc
import OperatorDiagram from 'rxjs-diagrams'

// Somewhere in your components...
<OperatorDiagram
  label=".distinctUntilChanged()"
  transform={obs => obs.distinctUntilChanged()}
  emissions={[
    { x: 5, d: 1 },
    { x: 35, d: 1 },
    { x: 70, d: 3 }
  ]}
  end={80}
  completion={80}
/>

Two input streams

Having multiple input streams is as simple as passing multiple value arrays and accepting them in your transform function.

import { Observable } from 'rxjs'
import OperatorDiagram from 'rxjs-diagrams'

// Somewhere in your components...
<OperatorDiagram
  label=".combineLatest((x, y) => '' + x + y)"
  transform={(a, b) => Observable.combineLatest(a, b, (x, y) => '' + x + y)}
  emissions={[
    [
      { x: 5, d: 1 },
      { x: 35, d: 2 },
      { x: 70, d: 3 }
    ], [
      { x: 10, d: 'A' },
      { x: 45, d: 'B' },
      { x: 80, d: 'C' }
    ]
  ]}
  end={80}
  completion={80}
/>

API

Exports:

  • transformEmissions
  • EmissionsView (Docs TODO)
  • TransitionEmissionsView (Docs TODO)
  • DraggableEmissionsView (Docs TODO)
  • ChainDiagram (Docs TODO)
  • OperatorDiagram (also the default export)

Emissions, End & Completion

The common three values that describe your input are: emissions, end, and completion. This is enough for this library to generate an input observable.

Emissions are an array of objects, which have a time value x and a label d. The value x must be a number. (Example: { x: 5, d: 'A' })

Completion is the time value when your observable completes. It is a number and usually you'll want it to be larger than all x values of your emissions.

End is where the component stops to draw your observable. It basically defines how long in time the diagram is. So if your end is 20 and an emission's x is 10, then the emission will be drawn right in the center.

OperatorDiagram

Props

  • label?: string: Some text that describes your transformation.

  • transform: (...input, scheduler): A function that transforms the input observables and produces an output. It receives the input observables as the first arguments and the scheduler last. You will need the scheduler to transform the virtual observable's time. For example for delay. More information on Schedulers here

  • emissions: Emission[] | Emission[][]: Here you can pass an array of emissions (described above) or an array of an array of emissions, in case you want multiple input observables.

  • end: number: Described above.

  • completion: number: Described above.

  • width: number: The width of the resulting SVG.

  • height: number: The height of the resulting SVG component.

More Repositories

1

setup-simple-ipsec-l2tp-vpn

Setup a simple IPSec/L2TP VPN Server for Ubuntu and Debian
Shell
644
star
2

setup-strong-strongswan

[UNMAINTAINED] Setup a (really) strong StrongSwan VPN Server for Ubuntu and Debian
Shell
633
star
3

fluorine

[UNMAINTAINED] Reactive state and side effect management for React using a single stream of actions
JavaScript
286
star
4

sweetsour

A CSS-in-JS parser and pipeline adhering to the ISTF spec 🍭
OCaml
224
star
5

docker-strongswan

Docker image for easily setting up a secure StrongSwan VPN
Shell
178
star
6

prosemd-lsp

An experimental proofreading and linting language server for markdown files ✍️
Rust
142
star
7

spectacle-sync

πŸ’ Present Spectacle presentations synchronised on multiple devices
JavaScript
59
star
8

extendable-immutable

Wrapper classes around Immutable.js that turn it inheritable
JavaScript
58
star
9

bunpkg

A proof of concept clone of Unpkg running on Cloudflare Workers
TypeScript
49
star
10

stream-tag

A tagged template literal utility for Node streams
TypeScript
47
star
11

react-compat-component

Marrying ES6 with mixins and more: Compatibility layer for React's ES6 Component class
JavaScript
39
star
12

Adventurous-Syntax

A dark Atom theme using common colors often seen in the cult series Adventure Time.
CSS
28
star
13

react-wonka

Several hooks for using Wonka streams with React
TypeScript
26
star
14

moomin

An experimental JSX/component framework around Reprocessing for Reason
OCaml
17
star
15

graphql-box

[WIP] Instant GraphQL OpenCRUD database that is universally runnable & deployable
TypeScript
17
star
16

pessimism

A fast HAMT Map intended for KV caching and optimistic updates
OCaml
15
star
17

bs-rebel

A toolkit for collections for bsb-native and bsb aimed at bundle size and performance
OCaml
14
star
18

kitten.sh

My collection of posts as found at kitten.sh
JavaScript
12
star
19

redux-fluorine

A Redux enhancer to manage groups of actions as observables ("agendas")
JavaScript
12
star
20

hachiko

WIP: Modular and performant data collections for JavaScript
TypeScript
10
star
21

bs-flow-parser

Flow's JavaScript parser, packaged and adapted for BuckleScript
OCaml
10
star
22

runruntypes

A poor man's runtime-only type checker
JavaScript
9
star
23

system

Nix
9
star
24

vim-adventurous

A dark vim color theme using common colours often seen in the cult series Adventure Time
Vim Script
9
star
25

react-static-plugin-md-pages

react-static plugin to create nested pages from a given source directory
JavaScript
7
star
26

goethe

Node module for immutable color conversion and manipulation
JavaScript
6
star
27

dotfiles

Vim Script
6
star
28

2g

WIP: A cross-platform creative coding framework for Reason
C
6
star
29

didsmoosh

componentDidSmoosh is a comedy night for JS nerds bringing together experts of developer humour on stage
JavaScript
6
star
30

fix-ubuntu-unicorn-for-macbooks

A wizard which can fix multiple issues, bugs and quirks occuring on Macbook Pros running Ubuntu 14.10.
Shell
5
star
31

nightingale

Reason
4
star
32

reason-hmm

HandmadeMath Bindings for OCaml
C++
4
star
33

reason-glsl-optimizer

GLSL Optimizer Bindings for OCaml
C++
4
star
34

threed-example-api

A GraphQL Example API for threaded conversations
JavaScript
4
star
35

advent-of-code-2019

Learning some Rust with "Advent of Code 2019" β€” because why not?
Rust
4
star
36

bowtie

JavaScript
4
star
37

thought-leader

JavaScript
3
star
38

concurrent-mode-deck

JavaScript
3
star
39

gatsby-theme-docs-system

JavaScript
3
star
40

twitter-was-down-

2
star
41

gatsby-theme-mdx-deck

Modified version of mdx-deck's Gatsby Theme with fixed size slides
JavaScript
2
star
42

vierdreidrei

433Mhz Receiver and Transmitter Module through a RCSwitch wrapper (WIP)
C++
1
star
43

pebble-barely-v2

A simple watchface only using horizontal and vertical straight lines for the Pebble smartwatch. Four squares for the time, four for the date, and four for the year, filling the whole screen. Also invertable!
C
1
star
44

kitten

1
star