Skip to content

signify

The main factory function to create a new Signify instance for reactive state management in React applications.

Description

signify is the core function that creates a reactive state container with various features like caching, synchronization, and conditional updates. It provides a comprehensive state management solution with built-in reactivity for React components.

Input/Output

InputTypeDescription
initialValueTThe initial value for the state
configTSignifyConfig (optional)Configuration object with cache and sync options
OutputTypeDescription
ReturnsSignify<T>A signify instance with reactive state management methods

Configuration Options

PropertyTypeDescription
cacheTCacheConfigCache configuration for localStorage/sessionStorage
syncKeystringKey for cross-tab synchronization

Example

typescript
import { signify } from 'react-signify';

// Basic usage
const sCounter = signify(0);

// With caching
const sUser = signify({ name: 'John', age: 25 }, {
  cache: {
    key: 'user-data',
    type: 'LocalStorage'
  }
});

// With sync across tabs
const sSharedState = signify('hello', {
  syncKey: 'shared-data'
});

Released under the MIT License.