Set

NPM
v0.5.0

#Installation

npm install @solid-primitives/set
yarn add @solid-primitives/set
pnpm add @solid-primitives/set

#Readme

The Javascript built-in Set & WeakSet data structures as a reactive signals.

  • ReactiveSet - A reactive version of a Javascript built-in Set class.
  • ReactiveWeakSet - A reactive version of a Javascript built-in WeakSet class.

#ReactiveSet

A reactive version of a Javascript built-in Set class.

#How to use it

#Import

import { ReactiveSet } from "@solid-primitives/set";

#Basic usage

const set = new ReactiveSet([1, 1, 2, 3]);

// listen for changes reactively
createEffect(() => {
  [...set]; // => [1,2,3] (reactive on any change)
  set.has(2); // => true (reactive on change to the result)
});

// apply like with normal Set
set.add(4);
set.delete(2);
set.clear();

#ReactiveWeakSet

A reactive version of a Javascript built-in WeakSet class.

#How to use it

#Import

import { ReactiveWeakSet } from "@solid-primitives/set";

#Basic usage

const set = new ReactiveWeakSet([1, 1, 2, 3]);

// listen for changes reactively
createEffect(() => {
  set.has(2); // => true (reactive on change to the result)
});

// apply changes like with normal Set
set.add(4);
set.delete(2);

#Changelog

See CHANGELOG.md