lateinit vars seem to suggest itself for certain things when programming for Android, like:
- fields for views that are available after they have been inflated in
- fields for non-optional arguments that have been passed to the fragment in
I did it this way but now came across a race condition where a parent fragment would try to query a lateinit field of a child fragment (via
childFragmentManager.findFragmentByTag(...)?.thatOneLateinitFieldThatIsInitializedInOnCreate and failed because the lateinit field was not initialized yet.
So apparently, a parent fragment can find a child fragment before
onCreate on the child fragment has been called. This design makes it problematic to use any lateinit var for the above mentioned use cases.