Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stagas/minimal-reactive
Smallest possible implementation of reactive programming, effects and dependencies.
https://github.com/stagas/minimal-reactive
Last synced: 14 days ago
JSON representation
Smallest possible implementation of reactive programming, effects and dependencies.
- Host: GitHub
- URL: https://github.com/stagas/minimal-reactive
- Owner: stagas
- License: mit
- Created: 2022-11-03T14:52:20.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-28T07:06:22.000Z (almost 2 years ago)
- Last Synced: 2024-10-07T08:10:09.125Z (about 1 month ago)
- Language: TypeScript
- Size: 29.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
minimal-reactiveSmallest 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
```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
# Change
IDep
# set
(value) } # current
undefined | null
| T
stackErr
Error
subs
Set<any>
value
undefined | null
| T
trigger
()
trigger() =>
- void
Boxs
# Dep
# Fx
# (deps, changes, prev)
OffFx
# Sub
# (prevValue, nextValue)
Unboxs
# Vals
# dep
(value) # deps
(obj) # effect
(deps, fn)
## Credits
- [everyday-types](https://npmjs.org/package/everyday-types) by [stagas](https://github.com/stagas) – Everyday utility types
- [everyday-utils](https://npmjs.org/package/everyday-utils) by [stagas](https://github.com/stagas) – Everyday utilities
## Contributing
[Fork](https://github.com/stagas/minimal-reactive/fork) or [edit](https://github.dev/stagas/minimal-reactive) and submit a PR.
All contributions are welcome!
## License
MIT © 2022 [stagas](https://github.com/stagas)