minimal-reactive
Smallest possible implementation of reactive programming, effects and dependencies.
npm i minimal-reactive
|
pnpm add minimal-reactive
|
yarn add minimal-reactive
|
Examples
# basic
# view source
example/basic.ts
import { dep, effect } from 'minimal-reactive'
const a = dep(3)
const b = dep(4)
effect({ a, b }, ({ a, b }) => {
// a + b are unboxed here
const result = a + b
console.log(result)
return () => {
// dispose
}
}) // prints 7
// changing values
a.value = 2 // prints 6
b.value = 3 // prints 5
API
}
Credits
- everyday-types by stagas – Everyday utility types
- everyday-utils by stagas – Everyday utilities
Contributing
All contributions are welcome!