subjecto
TypeScript icon, indicating that this package has built-in type declarations

0.0.53 • Public • Published

Gitpod ready-to-code CircleCI npm

Subjecto

What is it?

Subjecto is a minimalistic state management library with no dependencies. Its API is inspired from RxJs' Subject.

API

import { subject } from "subjecto";

// init
const value = new subject(new Date().toISOString())

// subscribe
const handler = value.subscribe((newValue) => {
  console.log("subscription 1", newValue);
});

// optionally, set debug to true to see all listeners and value updates
value.debug = true;

// push a new value
value.next(new Date().toISOString());

// get handlers uid
console.log(handler.id);

// unsubscribe
handler.unsubscribe();

// flush all subscriptions
value.complete();

Live Demo

https://codesandbox.io/s/distracted-meadow-vsqwd?file=/src/index.ts

Licence

MIT

Dependencies (0)

    Dev Dependencies (5)

    Package Sidebar

    Install

    npm i subjecto

    Weekly Downloads

    1,137

    Version

    0.0.53

    License

    MIT

    Unpacked Size

    762 kB

    Total Files

    90

    Last publish

    Collaborators

    • aelythe