npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@connectv/core

v0.2.8

Published

agent-based reactive programming library for typescript/javascript

Downloads

335

Readme

npm i @connectv/core

Minzipped size Build Status CodeFactor Chat on Gitter

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');

//
// Will say hello to everyone but 'Donald'.
// For obvious reasons.
//

wrap(fromEvent(a, 'input'))           // --> wrap the `Observable` in a `Pin`
.to(map(() => a.value))               // --> map the event to value of the input
.to(filter(name => name != 'Donald')) // --> filter 'Donald' out
.to(map(name => 'hellow ' + name))    // --> add 'hellow' to the name
.subscribe(msg => p.innerHTML = msg); // --> write it to the <p> element

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();                       // --> gate helps us control the flow of the words

group(control(), g.output)            // --> open the gate every time it outputs something (also once initially)
  .to(pin())                          // --> this relays either gate output or initial `control()` emit
  .to(pipe(delay(500)))               // --> but wait 500ms before opening the gate
  .to(g.control);                     // --> controls when the gate opens up.

wrap(fromEvent(a, 'input'))           // --> wrap the `Observable` in a `Pin`
  .to(pipe(debounceTime(2000)))       // --> debounce for 2 seconds so people are done typing
  .to(map(() => a.value.split(' ')))  // --> map the event to value of input, splitted
  .to(spread())                       // --> spread the array to multiple emissions
  .to(g)                              // --> pass those emissions to the gate
  .to(sink(() => p.classList.add('faded')))    // --> fade the <p> when something comes out of the gate.
  .to(pipe(delay(100)))                        // --> wait 100 ms
  .to(sink(v => p.innerHTML = v))              // --> write the new word
  .to(sink(() => p.classList.remove('faded'))) // --> show the <p> again
  .subscribe();                                // --> bind everything.

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/[email protected]/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.