@nomyx/gun-sync
Version:
A lightweight, powerful library for synchronizing application state in real-time using Gun.js.
18 lines (17 loc) • 645 B
TypeScript
import { IGunInstance } from 'gun';
export type SetItem<T> = T & {
id: string;
};
export interface GunSetActions<T> {
addItem: (item: T) => string;
updateItem: (id: string, item: Partial<T>) => void;
removeItem: (id: string) => void;
}
/**
* A React hook to manage a synchronized set of data.
*
* @param scope - A string to namespace the set data.
* @param gunInstance - Optional Gun instance. If not provided, uses context.
* @returns A tuple containing the array of items and actions to modify the set.
*/
export declare function useGunSet<T>(scope: string, gunInstance?: IGunInstance): [SetItem<T>[], GunSetActions<T>];