Skip to content

Commit dddf1f3

Browse files
committed
doc: update example
1 parent b449290 commit dddf1f3

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ A lightweight, composable and explicit reactivity system.
1414
## Features
1515

1616
<details>
17-
<summary>Plain reactivity. No proxies, no magic.</summary>
17+
<summary>Plain reactivity. No proxies, no magic.</summary>
1818

1919
It does not convert the value with `Object.defineProperty` nor `Proxy`. Keeping everything as plain JavaScript value makes it easier to work with other libraries and easier for the JavaScript engine to optimize.
2020

@@ -31,7 +31,7 @@ setCount(1);
3131
</details>
3232

3333
<details>
34-
<summary>Explicit reactivity. No hidden dependencies, no surprises.</summary>
34+
<summary>🔍 Explicit reactivity. No hidden dependencies, no surprises.</summary>
3535

3636
Unlike signal-based libraries, `@embra/reactivity` does not automatically track dependencies. You explicitly define what to watch and how to react to changes. This is easier to reason about dependencies and also reduce the cost of complex implicit dependency calculation.
3737

@@ -64,7 +64,7 @@ watch(get => {
6464
</details>
6565

6666
<details>
67-
<summary>Zero-cost ownership model. Type-safe lifecycle management.</summary>
67+
<summary>🛡️ Zero-cost ownership model. Type-safe lifecycle management.</summary>
6868

6969
In practice, one of the biggest problems we face with reactivity libraries is the lifecycle management of reactive values. `@embra/reactivity` provides a zero-cost ownership model that allows you to create reactive values with explicit ownership.
7070

@@ -96,9 +96,9 @@ count2$.set(2);
9696
</details>
9797

9898
<details>
99-
<summary>Flexible abstractions of state and actions.</summary>
99+
<summary>🧩 Flexible abstractions of state and actions.</summary>
100100

101-
In the days of Flux model, we often used a single store to hold the state and actions to mutate the state. This was nice for reasoning about the state, but it also introduced a lot of boilerplate code.
101+
In the days of Flux reducer model, we often used a single store to hold the state and actions to mutate the state. This was nice for reasoning about the state, but it also introduced a lot of boilerplate code.
102102

103103
Later on, a pattern with state and action glued together was introduced, like `redux-actions`. `@embra/reactivity` takes this a step further by providing a more simple and flexible abstraction of state and actions.
104104

@@ -124,23 +124,25 @@ trace(count$);
124124
</details>
125125

126126
<details>
127-
<summary>Framework agnostic. First-class support for React.</summary>
127+
<summary>🏗️ Framework agnostic. First-class support for React.</summary>
128128

129129
`@embra/reactivity` is designed to be framework agnostic. It can be used with any framework or library that supports JavaScript. It also provides first-class support for React.
130130

131131
```tsx
132132
import { writable } from "@embra/reactivity";
133-
import { useDerived, useCombined } from "@embra/reactivity/react";
133+
import { useValue, useDerived, useCombined } from "@embra/reactivity/react";
134134

135135
const count$ = writable(0);
136136

137137
function Counter({ count$ }) {
138-
const count = useDerived(count$);
138+
const count = useValue(count$);
139+
const countDouble = useDerived(count$, count => count * 2);
139140
return (
140141
<div>
141142
<button onClick={() => count$.set(count - 1)}>-</button>
142143
<span>{count}</span>
143144
<button onClick={() => count$.set(count + 1)}>+</button>
145+
<span>{countDouble}</span>
144146
</div>
145147
);
146148
}
@@ -149,7 +151,7 @@ function Counter({ count$ }) {
149151
</details>
150152

151153
<details>
152-
<summary>Small bundle size. Focused on performance and simplicity.</summary>
154+
<summary>📦 Small bundle size. Focused on performance and simplicity.</summary>
153155

154156
![export size](https://embrajs.github.io/reactivity/assets/export-size.svg)
155157

0 commit comments

Comments
 (0)