Skip to main content

Overview

Zeus uses the BLoC (Business Logic Component) pattern for state management. This provides predictable state updates and clear separation of concerns.

Why BLoC?

  • Predictable - State changes are explicit and testable
  • Scalable - Easy to add new features
  • Testable - Business logic separated from UI
  • Reactive - UI responds automatically to state changes

Core Concepts

Events

User actions or system events that trigger state changes:

States

Immutable representations of the UI at a point in time:

BLoC

Connects events to states:

Using BLoC in UI

Provide BLoC

Consume State

Best Practices

  1. Events are past tense - WalletCreated, not CreateWallet
  2. States are nouns - WalletLoaded, not LoadWallet
  3. BLoCs are pure - No side effects in mapEventToState
  4. UI is dumb - Only displays state, no business logic
  5. Test BLoCs - Test event-to-state transformations