Skip to content

feat: Implement MobX reactive state management for mobile app #42

Description

@rafamiziara

🎯 Objective

Implement MobX reactive state management to replace complex hook-based state management in the SuperPool mobile app.

📋 Background

Current mobile app has:

  • 39+ useState/useRef calls across 11 hooks
  • Complex useEffect dependency chains (8+ dependencies)
  • Manual state synchronization between authentication, wallet, and Firebase
  • Scattered state management making debugging difficult

🏗️ Implementation Phases

Phase 1: Foundation Setup ✅ COMPLETED

  • Install MobX packages (mobx, mobx-react-lite)
  • Create store architecture (AuthStore, WalletStore, PoolStore)
  • Set up Root Store pattern with React Context
  • Configure MobX for React Native environment
  • Add StoreProvider to app layout

Phase 2: Hook Migration

Core State Migration:

  • Authentication State Migration
    • Create bridge hook connecting existing useAuthenticationState to AuthenticationStore
    • Test bridge with one component
    • Verify no functionality breaks
  • Wallet Connection Migration
    • Replace connectionStateManager.ts with WalletConnectionStore
    • Update atomic state validation logic
    • Test wallet connection flows
  • Authentication Orchestration
    • Update AuthenticationOrchestrator to use stores
    • Replace complex useEffect with MobX autorun
    • Test complete authentication flow

Service Integration & Optimization:

  • Service Layer Updates
    • Update services to use stores directly
    • Remove callback parameters
    • Test service integration
  • Component Migration
    • Migrate dashboard.tsx (add observer wrapper)
    • Add pool management features to dashboard
    • Migrate connecting.tsx and onboarding.tsx
  • Complex Hook Simplification
    • Replace complex useEffect chains with reactions
    • Remove unnecessary state variables
    • Performance testing

Phase 3: Advanced Features

  • Real-time pool balance updates
  • Live transaction status tracking
  • Performance optimizations
  • MobX DevTools integration

🎯 Success Metrics

  • Reduce useState calls from 39+ to <10
  • Eliminate complex useEffect dependency arrays
  • Centralize error handling in stores
  • Improve component performance with observer()

📋 Acceptance Criteria

  • No functionality regressions during migration
  • All existing tests pass with MobX integration
  • Authentication flow works with stores instead of hooks
  • Wallet connection state managed by WalletStore
  • Dashboard component uses MobX for pool features
  • Performance improvements measurable with React DevTools
  • Bridge hooks removed after successful migration

🚀 Implementation Strategy

  1. Gradual migration - No breaking changes during Phase 2
  2. Bridge pattern - Old hooks work alongside new stores
  3. Component-by-component - Migrate one at a time
  4. Risk-based approach - Start with simple components, work up to complex hooks
  5. Full testing - Verify each migration step

Priority: High (Foundation for pool management features)
Effort: Large
Impact: High (Simplifies all future development)

Metadata

Metadata

Assignees

Labels

comp: frontendIssues for the mobile app UI/UX in packages/mobile-apptype: featureNew feature or request

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions