ts-reactx

1.0.2 • Public • Published

ts-reactx CI Status npm version Package Pipeline

A basic reactive system in TypeScript.

Reactive programming is a programming paradigm that focuses on how values are computed in terms of each other to allow a change to one value to automatically propagate to other values, like in a spreadsheet.

This system implements a basic reactive system with cells with settable values ("input" cells) and cells with values computed in terms of other cells ("compute" cells). It has a provision for "updates" so that when an input value is changed, values propagate to reach a new stable system state.

In addition, compute cells allow for registering change notification callbacks. A cell’s callbacks is called when the cell’s value in a new stable state has changed from the previous stable state.

References

Disclaimer

Usage

import Cell from './react'

let cell: Cell<number> = new Cell(1); // set a cell with value 1
const output = cell.getComputedCellFn(() => cell.readFn() + 1); // add a compute function
let result = output(); // result = 2

More examples in tests

Package Sidebar

Install

npm i ts-reactx

Weekly Downloads

0

Version

1.0.2

License

Apache-2.0

Unpacked Size

47.9 kB

Total Files

11

Last publish

Collaborators

  • shan96