Skip to content

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 ​

Setup Guide Usage ​

Each setup guide provides:

  1. Type Definitions - Reusable interface definitions for common patterns
  2. Context Creation - Standard context creation patterns with naming conventions
  3. Provider Setup - Provider composition and organization patterns
  4. Export Patterns - Best practices for exporting contexts and hooks
  5. 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:

Multi-Context Patterns ​

For applications using multiple contexts:

Advanced Patterns ​

For complex applications:

Configuration Best Practices ​

Type Organization ​

  1. Domain-Driven: Organize types by business domain
  2. Reusability: Create reusable type patterns for common operations
  3. Consistency: Use consistent naming conventions across domains
  4. Extensibility: Design types for future extension and modification

Context Management ​

  1. Clear Naming: Use descriptive names for contexts and hooks
  2. Domain Separation: Separate contexts by business or technical domains
  3. Provider Composition: Use utilities for clean provider organization
  4. Performance: Consider re-render implications of context structure

Setup Documentation ​

  1. Reference First: Always reference setup guides before duplicating code
  2. Customize Appropriately: Modify patterns to fit your specific needs
  3. Maintain Consistency: Follow established patterns across your application
  4. Update Centrally: Update setup guides when patterns evolve

Quick Reference Matrix ​

Use CaseAction ContextStore ContextRef ContextSetup 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✅✅OptionalMulti-Context Domain
Enterprise applications✅✅✅Multi-Context Enterprise

Integration with Pattern Documentation ​

These setup guides integrate with pattern documentation as follows:

Action Patterns ​

Store Patterns ​

Architecture Patterns ​

Ref Patterns ​

Performance Patterns ​

Provider Management ​

Released under the Apache-2.0 License.