Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep UI state model flat, avoid deep nesting #24

Open
forman opened this issue Nov 5, 2024 · 0 comments
Open

Keep UI state model flat, avoid deep nesting #24

forman opened this issue Nov 5, 2024 · 0 comments

Comments

@forman
Copy link
Member

forman commented Nov 5, 2024

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant