mikaelacaron / Basic-Car-Maintenance

A basic app to track your car's maintenance. Open source for Hacktoberfest 2023. Beginners are welcome!
https://mikaelacaron.github.io/Basic-Car-Maintenance/documentation/basic_car_maintenance/
Apache License 2.0
214 stars 123 forks source link

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

Closed windrunner21 closed 9 months ago

windrunner21 commented 9 months ago

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

Screenshot