Folks, can anyone tell me when viewModel is killed...
# android
s
Folks, can anyone tell me when viewModel is killed by process death what happens to
lateinit var sampleString: String
, will it be initialised with null or will remain uninitialised ?
j
If your process is killed, well then it will cease to exist
just like the rest of the process
as in it is killed
stops existing
Like what do you expect?
s
So my question is what will happen to member properties which are tagged with
lateinit var
j
well they die
s
Its sad they die but when it is recreated will they be assigned null value or will they preserve(which is not possible) or will they be remain un initialised.
j
a viewmodel is never recreated
an activity is recreated
a view model will be newly created
z
`lateinit var`s are initialized by the property delegate when the class is initialized (null represents “uninitialized”). Whether another instance of the process happened to exist at some point in the past or not is irrelevant.
👏 1
👌 1
j
all lateinit vars will therefore start at their uninitialized state