import { type Observable, type ObservableMaybe } from 'woby'; /** * A hook for managing boolean state with utility functions. * * This hook uses use to ensure the boolean state is always * represented as an observable, providing a consistent interface for * reactive state management. * * @param defaultValue - The initial boolean value (can be an observable or plain boolean) * @param clone - Optional. If true, creates a new observable even if the input * is already an observable. Defaults to false. * @returns An object containing: * - value: An observable boolean representing the current state * - setTrue: A function to set the value to true * - setFalse: A function to set the value to false * - toggle: A function to toggle between true and false * * @example * ```tsx * const { value, toggle, setTrue, setFalse } = useBoolean(false) * * return ( *
Value: {() => $$(value) ? 'ON' : 'OFF'}
* * * *