Skip to content

Commit 3c44d42

Browse files
committed
Use class signals
1 parent e54041d commit 3c44d42

File tree

4 files changed

+23
-24
lines changed

4 files changed

+23
-24
lines changed

frameworks/keyed/thyn/package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frameworks/keyed/thyn/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
},
1414
"devDependencies": {
1515
"vite": "6.3.5",
16-
"@thyn/vite-plugin": "0.0.175"
16+
"@thyn/vite-plugin": "0.0.218"
1717
},
1818
"dependencies": {
19-
"@thyn/core": "0.0.175"
19+
"@thyn/core": "0.0.218"
2020
}
2121
}

frameworks/keyed/thyn/src/App.thyn

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
import {data, buildData, selected} from "./state.thyn.js";
33
import Row from "./Row.thyn";
44

5-
const add = () => data(d => [...d, ...buildData(1000)]);
6-
const clear = () => data([]);
7-
const partialUpdate = () => {for (let i = 0, d = data(), len = d.length; i < len; i += 10) d[i].label(l => l + " !!!")};
5+
const add = () => data.update(d => [...d, ...buildData(1000)]);
6+
const clear = () => data.set([]);
7+
const partialUpdate = () => {for (let i = 0, d = data.get(), len = d.length; i < len; i += 10) d[i].label.update(l => l + " !!!")};
88
const run = () => {
9-
data(buildData(1000));
9+
data.set(buildData(1000));
1010
};
1111
const runLots = () => {
12-
data(buildData(10000));
12+
data.set(buildData(10000));
1313
};
14-
const swapRows = () => data(d => {
14+
const swapRows = () => data.update(d => {
1515
if (d.length > 998) {
1616
const clone = d.slice();
1717
const tmp = clone[1];
@@ -59,7 +59,7 @@
5959
</div>
6060
<table class="table table-hover table-striped test-data">
6161
<tbody>
62-
<Row #for={row in data()} row={row} />
62+
<Row #for={row in data.get()} row={row} />
6363
</tbody>
6464
</table>
6565
<span class="preloadicon glyphicon glyphicon-remove" aria-hidden="true"></span>

frameworks/keyed/thyn/src/Row.thyn

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
<script>
2-
import {selected, data } from "./state.thyn.js";
2+
import { selected, data } from "./state.thyn.js";
33

4-
const {row} = $props;
5-
const {id, label} = row;
4+
const { row: { id, label } } = $props;
65
</script>
76

8-
<tr class={selected() === id ? 'danger' : undefined}>
7+
<tr class={selected.get() === id ? 'danger' : undefined}>
98
<td class="col-md-1">{{ id }}</td>
109
<td class="col-md-4">
11-
<a onclick={() => selected(id)}>{{ label() }}</a>
10+
<a onclick={() => selected.set(id)}>{{ label.get() }}</a>
1211
</td>
1312
<td class="col-md-1">
14-
<a onclick={() => data(d => {
13+
<a onclick={() => data.update(d => {
1514
const clone = d.slice();
16-
clone.splice(clone.indexOf(row), 1);
15+
clone.splice(clone.findIndex(r => r.id === id), 1);
1716
return clone;
1817
})}>
1918
<span class="glyphicon glyphicon-remove" aria-hidden="true" />

0 commit comments

Comments
 (0)