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

fix: DashboardView events Aren't Loading on the First Load #273

Conversation

windrunner21
Copy link
Contributor

What it Does

How I Tested

  • Run the application with Dashboard tab open.
  • 2 of my maintenance events that I created loaded right away. First loading indicator was shown, later events themselves.
  • Switched to Odometer tab and back to Dashboard, loaded once again correctly.
  • Run the application with Odometer tab open.
  • Switched to Dashboard tab, events loaded correctly.

Notes

  • I have a couple of notes here:
    1. @bindable macro was switched to @State because State is enough and correct one to use in this case as @State makes property both mutable and observable.

Later I had an issue that initializer would give me Variable 'self.viewModel' used before being initialized error, if I wrote the code as

    init(userUID: String?) {
        viewModel = DashboardViewModel(userUID: userUID)
    }

To be frank, this was a strange error for compiler to give in my opinion, so I read on the topic a bit and decided to use underscored version of the property - the actual underlying property that is accessed through projected value. In order to set it I need to use State(initialValue: ) that allows me to make initial value of the state equal to DashboardViewModel provided with userUID.

    1. Second note I would like to add is that on each tab change getMaintenanceEvents() or getOdometerReadings() are fired constantly, if data is not changed that results in overhead requests to Firebase.

Screenshot

Copy link
Owner

@mikaelacaron mikaelacaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!! Yeah this should definitely be State not Bindable

Second note I would like to add is that on each tab change getMaintenanceEvents() or getOdometerReadings() are fired constantly, if data is not changed that results in overhead requests to Firebase.

Yup, I'm thinking of redoing how I have the whole data model set up and how it's passing data between all these views, for this reason

@mikaelacaron mikaelacaron merged commit 25acad7 into mikaelacaron:dev Nov 29, 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

Successfully merging this pull request may close these issues.

BUG - DashboardView events Aren't Loading on the First Load
2 participants