Skip to content

Keep UI state model flat, avoid deep nesting #24

@forman

Description

@forman

Why:

Changing a deeply nested property is more complex, error prone, and takes more time to execute. Deeply nested state models are harder to understand too. It will also require changing all parent objects and arrays that contain the changed value which potentially causes more UI renders and/or more tests whether component properties changed.

How:

Go back to former design where initial contributions that stay constant are separate from changing contribution states and components.

export interface StoreState {
  ...
  contributionsResult: ApiResult<Contributions>;
  contribInfosRecord: Record<string, ContributionInfo[]>;
  contribComponentsRecord: Record<string, ComponentState[]>;
  contribStatesRecord: Record<string, ContributionState[]>;
}

This will help implementing #21 because we can then listen for changes in contribStatesRecord only (subscribe with selector).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions