Skip to content

Commit c8577b2

Browse files
committed
Bump deps
1 parent 633c338 commit c8577b2

File tree

3 files changed

+43
-46
lines changed

3 files changed

+43
-46
lines changed

frameworks/keyed/compostate-jsx/package-lock.json

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

frameworks/keyed/compostate-jsx/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"rollup-plugin-terser": "7.0.2"
3131
},
3232
"dependencies": {
33-
"compostate": "^0.2.1-beta.2",
34-
"compostate-jsx": "^0.2.1-beta.2"
33+
"compostate": "^0.2.1-beta.4",
34+
"compostate-jsx": "^0.2.1-beta.4"
3535
}
3636
}

frameworks/keyed/compostate-jsx/src/main.jsx

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
render,
33
} from 'compostate-jsx';
44
import {
5-
atom,
5+
signal,
66
map,
77
selector,
88
} from 'compostate';
@@ -19,7 +19,7 @@ function buildData(count) {
1919
for (let i = 0; i < count; i++) {
2020
data[i] = {
2121
id: idCounter++,
22-
label: atom(`${adjectives[_random(adjectives.length)]} ${colours[_random(colours.length)]} ${nouns[_random(nouns.length)]}`)
22+
label: signal(`${adjectives[_random(adjectives.length)]} ${colours[_random(colours.length)]} ${nouns[_random(nouns.length)]}`)
2323
};
2424
}
2525
return data;
@@ -34,22 +34,22 @@ const Button = ({ id, text, fn }) => (
3434
);
3535

3636
const Main = () => {
37-
const data = atom([]);
38-
const selected = atom(null);
37+
const [data, setData] = signal([]);
38+
const [selected, setSelected] = signal(null);
3939
function run() {
40-
data(buildData(1000));
40+
setData(buildData(1000));
4141
}
4242
function runLots() {
43-
data(buildData(10000));
43+
setData(buildData(10000));
4444
}
4545
function add() {
46-
data([...data(), ...buildData(1000)]);
46+
setData([...data(), ...buildData(1000)]);
4747
}
4848
function update() {
4949
const state = data();
5050
for (let i = 0, len = state.length; i < len ; i += 10) {
51-
const { label } = state[i];
52-
label(label() + ' !!!');
51+
const { label: [read, write] } = state[i];
52+
write(read() + ' !!!');
5353
}
5454
}
5555
function swapRows() {
@@ -58,19 +58,19 @@ const Main = () => {
5858
let tmp = newData[1];
5959
newData[1] = newData[998];
6060
newData[998] = tmp;
61-
data(newData);
61+
setData(newData);
6262
}
6363
}
6464
function clear() {
65-
data([]);
65+
setData([]);
6666
}
6767
function remove(id) {
6868
const state = data();
6969
const idx = state.findIndex(d => d.id === id);
70-
data([...state.slice(0, idx), ...state.slice(idx + 1)]);
70+
setData([...state.slice(0, idx), ...state.slice(idx + 1)]);
7171
}
7272
function select(id) {
73-
selected(id);
73+
setSelected(id);
7474
}
7575
const isSelected = selector(() => selected());
7676

@@ -95,23 +95,20 @@ const Main = () => {
9595
</div>
9696
<table class='table table-hover table-striped test-data'>
9797
<tbody>
98-
{map(() => data(), () => (row) => {
99-
const rowId = row.id;
100-
return (
101-
<tr class={isSelected(rowId) ? 'danger' : ''}>
102-
<td class='col-md-1' textContent={rowId} />
103-
<td class='col-md-4'>
104-
<a onClick={[select, rowId]} textContent={row.label()} />
105-
</td>
106-
<td class='col-md-1'>
107-
<a onClick={[remove, rowId]}>
108-
<span class='glyphicon glyphicon-remove' aria-hidden="true" />
109-
</a>
110-
</td>
111-
<td class='col-md-6'/>
112-
</tr>
113-
);
114-
})}
98+
{map(() => data(), ({ id, label: [label] }) => (
99+
<tr class={isSelected(id) ? 'danger' : ''}>
100+
<td class='col-md-1' textContent={id} />
101+
<td class='col-md-4'>
102+
<a onClick={[select, id]} textContent={label()} />
103+
</td>
104+
<td class='col-md-1'>
105+
<a onClick={[remove, id]}>
106+
<span class='glyphicon glyphicon-remove' aria-hidden="true" />
107+
</a>
108+
</td>
109+
<td class='col-md-6'/>
110+
</tr>
111+
))}
115112
</tbody>
116113
</table>
117114
<span class='preloadicon glyphicon glyphicon-remove' aria-hidden="true" />

0 commit comments

Comments
 (0)