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
| Input | Type | Description |
|---|---|---|
initialValue | T | The initial value for the state |
config | TSignifyConfig (optional) | Configuration object with cache and sync options |
| Output | Type | Description |
|---|---|---|
| Returns | Signify<T> | A signify instance with reactive state management methods |
Configuration Options
| Property | Type | Description |
|---|---|---|
cache | TCacheConfig | Cache configuration for localStorage/sessionStorage |
syncKey | string | Key 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'
});