Skip to content

Latest commit

 

History

History
45 lines (29 loc) · 1008 Bytes

readme.md

File metadata and controls

45 lines (29 loc) · 1008 Bytes

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

Licence

MIT