Skip to content

Store Patterns

Type-safe state management patterns without action dispatching overhead.

Prerequisites

For complete setup instructions including store definitions, context creation, and provider configuration, see Basic Store Setup.

All store pattern examples reference the shared setup guide for:

  • Store type definitions and configurations
  • Context creation patterns and naming conventions
  • Provider composition and organization
  • Export patterns and integration strategies

Overview

Store patterns provide excellent type inference and simplified API for pure state management scenarios.

Available Store Patterns

Core Patterns

Computed Value Patterns

Performance & Optimization

Advanced Patterns

Quick Reference

Pattern CategoryPurposeBest For
Core PatternsBasic store operationsData layers, subscriptions, multi-store access
Computed ValuesDerived state calculationsReactive calculations, data transformations
Performance & OptimizationPerformance optimizationMemory management, batching, memoization
Advanced PatternsComplex scenariosProvider composition, custom configurations

Detailed Pattern Reference

Specific PatternPurposeUse When
Basic UsageType-safe state managementStarting with stores
useStoreValueCore store subscriptionsSelective updates, conditional subscriptions
useComputedStoreDerived state calculationsComputed values, multi-store calculations
MemoizationPrevent re-rendersPerformance optimization needed
Memory ManagementResource efficiencyMemory leaks detected
Error HandlingRobust operationsProduction applications

When to Use Store Patterns

  • Pure State Management: No complex business logic needed
  • Data Layers: Managing application data without side effects
  • Configuration State: User preferences, app settings
  • UI State: View state, form state, component state
  • Reactive Data: Data that needs reactive subscriptions

Key Features

  • ✅ Excellent type inference without manual type annotations
  • ✅ Simplified API focused on store management
  • ✅ Direct value or configuration object support
  • ✅ No need for separate createStore calls
  • ✅ Multiple comparison strategies for performance
  • ✅ HOC pattern for automatic Provider wrapping

Integration

Store patterns work best when combined with:

Architecture & Troubleshooting

Technical Architecture

Common Issues

Key Learning Path

  1. Start with: Basic Usage and useStoreValue Patterns
  2. Understand integration: Immutability & Comparison Integration
  3. Optimize performance: Store Performance Overview
  4. Troubleshoot issues: Common Misconceptions

Released under the Apache-2.0 License.