Correctly shows maintenance events on first load of the application.
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:
@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
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.
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.
What it Does
How I Tested
Notes
Later I had an issue that initializer would give me
Variable 'self.viewModel' used before being initialized
error, if I wrote the code asTo 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 toDashboardViewModel
provided withuserUID
.getMaintenanceEvents()
orgetOdometerReadings()
are fired constantly, if data is not changed that results in overhead requests to Firebase.Screenshot