-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDerivedStore.expected
More file actions
29 lines (23 loc) · 684 Bytes
/
Copy pathDerivedStore.expected
File metadata and controls
29 lines (23 loc) · 684 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { useStore, Derived, Store } from "@tanstack/solid-store";
export const countStore = new Store(5);
export const doubledOptions = {
fn: (props) => ((countStore.state * 2) | 0),
deps: [countStore],
};
export const doubled = new Derived(doubledOptions);
export function Component() {
const count = useStore(countStore, (s) => (s | 0));
return <div>
<span>
{`Count: ${count()}`}
</span>
<span>
{`Doubled: ${doubled.state}`}
</span>
<button on:click={(_arg) => {
countStore.setState((s_1) => ((s_1 + 1) | 0));
}}>
Increment
</button>
</div>;
}