deno.land / x / solid_signals@solid-signals@1.3.7 / src / signals / composable / createSet
Extends signal setter with set
, delete
and clear
methods. See Reference for more details.
import { createSet } from "solid-signals";
function ExampleComponent {
const [set, setSet] = createSet(new Set<number>());
return (
<div>
<button onClick={() => {
setSet.add(set().size);
}}>
Add
</button>
set: {JSON.stringify([...set()])}
</div>
);
}
set: []
[Click: Add]
set: [0]
[Click: Add]
set: [0, 1]
import { createHistory, createSet } from "solid-signals";
function ExampleComponent {
const [set, setSet] = createSet.wrap(createHistory({ prop1: "value1", prop2: "value2" }));
return (
<div>
<button onClick={() => {
setSet.add(set().size);
}}>
Add
</button>
<button onClick={() => {
setSet.history.back();
}}>
Back
</button>
set: {JSON.stringify([...set()])}
</div>
);
}
set: []
[Click: Add]
set: [0]
[Click: Add]
set: [0, 1]
[Click: Back]
set: [0]
[Click: Back]
set: []
The following methods use the same api as the built-in JavaScript Set, the following links lead to MDN.
Version Info