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

Refactor SearchScreen #14

Open
rafsanjani opened this issue Feb 26, 2023 · 0 comments
Open

Refactor SearchScreen #14

rafsanjani opened this issue Feb 26, 2023 · 0 comments

Comments

@rafsanjani
Copy link

rafsanjani commented Feb 26, 2023

You can improve SearchScreen by applying the following;

  • Do not pass the ViewModel object down to its children. Instead, extract the data you need from the ViewModel and pass those data along.
  • Make all other functions in SearchScreen private to prevent namespace pollution.
  • ObserveCurrentTime is quite misleading because it does more than just time observation. It also emits UI components.
  • You are exposing Mutable data types from your ViewModel to the public. Normally, you would want your ViewModel to only expose states to the UI. The sequence of UI->VM usually goes along these lines;
    UI: Observes state from the VM
    UI: Invokes a function from the VM
    VM: Performs an operation
    VM: Updates a state internally and publishes to subscribers
    UI: Receives new state updates and refreshes components accordingly.
@rafsanjani rafsanjani changed the title Add preview for SearchScreen Refactor SearchScreen Feb 26, 2023
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