UNPKG

770 BTypeScriptView Raw
1export declare class ObservableSet<V> extends Set<V> {
2 private readonly listener;
3 constructor(listener: (map: ObservableSet<V>) => void, init?: Iterable<V>);
4 add(value: V): this;
5 delete(value: V): boolean;
6 clear(): void;
7}
8/**
9 * Create and return a [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) that triggers rerenders when it's updated.
10 *
11 * ```ts
12 * const ids = useSet<number>([1,2,3,4]);
13 *
14 * return (
15 * <>
16 * {Array.from(ids, id => (
17 * <div>
18 * id: {id}. <button onClick={() => ids.delete(id)}>X</button>
19 * </div>
20 * )}
21 * </>
22 * )
23 * ```
24 *
25 * @param init initial Set values
26 */
27declare function useSet<V>(init?: Iterable<V>): ObservableSet<V>;
28export default useSet;
29
\No newline at end of file