Setup & Configuration
Shared setup patterns and configurations for the Context-Action framework.
Overview
This section provides reusable setup patterns that can be referenced across all pattern documentation. Instead of duplicating setup code in every document, these shared configurations serve as the foundation for all Context-Action implementations.
Available Setup Guides
Core Setup Patterns
- Basic Action Setup - Action context setup patterns and type definitions
- Basic Store Setup - Store context setup patterns and configurations
- Multi-Context Setup - Complex architecture setup for large applications
Setup Guide Usage
Each setup guide provides:
- Type Definitions - Reusable interface definitions for common patterns
- Context Creation - Standard context creation patterns with naming conventions
- Provider Setup - Provider composition and organization patterns
- Export Patterns - Best practices for exporting contexts and hooks
- Configuration Options - Advanced configuration for different scenarios
How to Use Setup Guides
1. Reference in Pattern Documents
Pattern documents reference these setup guides instead of duplicating configuration code:
markdown
## Prerequisites
See [Basic Action Setup](../setup/basic-action-setup.md) for action context configuration.2. Copy and Customize
Use the provided patterns as starting points and customize for your specific domain:
typescript
// From Basic Action Setup - customize for your domain
interface MyDomainActions {
// Copy base pattern and modify
createItem: { data: MyDomainData };
updateItem: { id: string; data: Partial<MyDomainData> };
deleteItem: { id: string };
}3. Import Shared Types
Import and extend shared type definitions:
typescript
import { CRUDActions, UserActions } from '../setup/basic-action-setup';
interface MyAppActions extends CRUDActions, UserActions {
customAction: { payload: any };
}Setup Pattern Categories
Single Context Patterns
For applications using one context type:
- Simple action dispatching → Basic Action Setup
- Basic state management → Basic Store Setup
Multi-Context Patterns
For applications using multiple contexts:
- MVVM architecture → Multi-Context Setup
- Domain-driven design → Multi-Context Setup
- Enterprise applications → Multi-Context Setup
Advanced Patterns
For complex applications:
- Cross-context communication → Multi-Context Setup
- Performance optimization → Multi-Context Setup (RefContext)
- Provider composition → All setup guides include composition patterns
Configuration Best Practices
Type Organization
- Domain-Driven: Organize types by business domain
- Reusability: Create reusable type patterns for common operations
- Consistency: Use consistent naming conventions across domains
- Extensibility: Design types for future extension and modification
Context Management
- Clear Naming: Use descriptive names for contexts and hooks
- Domain Separation: Separate contexts by business or technical domains
- Provider Composition: Use utilities for clean provider organization
- Performance: Consider re-render implications of context structure
Setup Documentation
- Reference First: Always reference setup guides before duplicating code
- Customize Appropriately: Modify patterns to fit your specific needs
- Maintain Consistency: Follow established patterns across your application
- Update Centrally: Update setup guides when patterns evolve
Quick Reference Matrix
| Use Case | Action Context | Store Context | Ref Context | Setup Guide |
|---|---|---|---|---|
| Simple UI events | ✅ | ❌ | ❌ | Basic Action |
| Basic state management | ❌ | ✅ | ❌ | Basic Store |
| Form handling | ✅ | ✅ | ❌ | Both Basic guides |
| Performance optimization | ✅ | ✅ | ✅ | Multi-Context |
| MVVM architecture | ✅ | ✅ | ✅ | Multi-Context MVVM |
| Domain separation | ✅ | ✅ | Optional | Multi-Context Domain |
| Enterprise applications | ✅ | ✅ | ✅ | Multi-Context Enterprise |
Integration with Pattern Documentation
These setup guides integrate with pattern documentation as follows:
Action Patterns
- Action Basic Usage → Uses Basic Action Setup
- Dispatch Access Patterns → Uses Basic Action Setup
- Advanced Action Patterns → Uses Multi-Context Setup
Store Patterns
- Store Basic Usage → Uses Basic Store Setup
- Store Performance Patterns → Uses Basic Store Setup
- Store Manager API → Uses Basic Store Setup
Architecture Patterns
- MVVM Architecture → Uses Multi-Context Setup
- Domain Context Architecture → Uses Multi-Context Setup
- Context Splitting Patterns → Uses Multi-Context Setup
Ref Patterns
- Ref Basic Usage → Uses RefContext Setup
- Canvas Optimization → Uses RefContext Setup
- Memory Optimization → Uses RefContext Setup
Performance Patterns
- Optimization Techniques → Uses all setup guides
Provider Management
Related Guides
- Pattern Selection Guide - Choose the right patterns for your use case
- Best Practices - General framework best practices
- Architecture Guide - Overall architecture concepts