UNPKG

@nomyx/gun-sync

Version:

A lightweight, powerful library for synchronizing application state in real-time using Gun.js.

12 lines (11 loc) 606 B
import { IGunInstance } from 'gun'; /** * A React hook to synchronize a piece of state with Gun.js. * * @param scope - A string to namespace the data. * @param key - The key for the data within the scope. * @param initialValue - The default value if none is set in the database. * @param gunInstance - Optional Gun instance. If not provided, uses context. * @returns A state pair `[value, setValue]`, similar to `React.useState`. */ export declare function useGunState<T>(scope: string, key: string, initialValue: T, gunInstance?: IGunInstance): [T, (newValue: T | ((prevState: T) => T)) => void];