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

0.0.0 • Public • Published

inertial

A tiny library for integrating reactive signals anywhere.

  • Zero dependencies and tiny bundle (around 700B min+gzip)
  • Predictable memory management
  • Smallest CPU overhead
  • TypeScript typings included
import { ObservableScope } from "inertial";

/* Create isolated scope that has its own lifecycle */
let os = ObservableScope();

/* Use signals to define values and relations between them */
let counter = os.signal(0);
let doubled = os.derive(() => counter() * 2);

/* Use watchers to track value changes and perform side effects */
let output = document.getElementById("output");
os.watch(() => {
  output.innerText = doubled();
});

/* Trigger value updates that will ensure all relations updated as well */
let trigger = document.getElementById("trigger");
trigger.addEventListener("click", () => {
  counter((value) => value + 1);
});

Readme

Keywords

none

Package Sidebar

Install

npm i inertial

Weekly Downloads

1

Version

0.0.0

License

none

Unpacked Size

6.9 kB

Total Files

4

Last publish

Collaborators

  • alexeyraspopov