-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84ed05d
commit ca4fc93
Showing
5 changed files
with
38 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,31 @@ | ||
# Reactivity | ||
# dataflow | ||
|
||
A tiny library for integrating reactive signals anywhere. Memory-efficient, least CPU overhead. | ||
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 | ||
|
||
```js | ||
import { ObservableScope } from "dataflow"; | ||
|
||
/* 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); | ||
}); | ||
``` |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
{ | ||
"name": "reactivity", | ||
"type": "module" | ||
"name": "dataflow", | ||
"version": "0.0.0", | ||
"type": "module", | ||
"files": [ | ||
"dataflow.d.ts", | ||
"dataflow.js" | ||
] | ||
} |