npm i @connectv/core
CONNECTIVE facilitates large-scale reactive programming in Type(Java)Script. It enables declarative creation of large and complex data/event flows and supports re-use of flows.
Example (Stackblitz):
import { wrap, map, filter } from '@connectv/core';
import { fromEvent } from 'rxjs';
let a = document.getElementById('a') as HTMLInputElement;
let p = document.getElementById('p');
wrap(fromEvent(a, 'input'))
.to(map(() => a.value))
.to(filter(name => name != 'Donald'))
.to(map(name => 'hellow ' + name))
.subscribe(msg => p.innerHTML = msg);
CONNECTIVE is a thin layer on top of RxJS, so it provides all the toolset of rxjs by proxy. However, while RxJS's API is better suited for short-lived and small flows, CONNECTIVE adds tools better suiting long-living and large/complex flows.
Example (Stackblitz):
import './style.css';
import { wrap, gate, control, map, pin, pipe, group, spread, sink } from '@connectv/core';
import { fromEvent } from 'rxjs';
import { delay, debounceTime } from 'rxjs/operators';
let a = document.getElementById('a') as HTMLInputElement;
let p = document.getElementById('p');
let g = gate();
group(control(), g.output)
.to(pin())
.to(pipe(delay(500)))
.to(g.control);
wrap(fromEvent(a, 'input'))
.to(pipe(debounceTime(2000)))
.to(map(() => a.value.split(' ')))
.to(spread())
.to(g)
.to(sink(() => p.classList.add('faded')))
.to(pipe(delay(100)))
.to(sink(v => p.innerHTML = v))
.to(sink(() => p.classList.remove('faded')))
.subscribe();
How To Install
Using NPM:
npm i @connectv/core
Using a CDN:
<script src="https://unpkg.com/rxjs/bundles/rxjs.umd.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.14/lodash.min.js"></script>
<script src="https://unpkg.com/@connectv/core/dist/bundles/connective.es5.min.js"></script>
How To Use
Check out the documentation.
Why Use This?
CONNECTIVE provides a different API on top of RxJS that is more suitable for larger and more complex projects.
You can read more on this here.
How To Contribute
Check out the contribution guide. Also check out the code of conduct.