Skip to content

paulbrie/subjecto

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published