What happens when a `View` is in `GONE` state and ...
# android
s
What happens when a
View
is in
GONE
state and
LiveData
is supposed to set value on it? Does
LiveData
do anything or skip setting value or does it set it but since the view is gone we won't be able to see changes?
😶 1
k
I believe it's the latter. Since all LiveData does is propagate the state from models to UI (Views). Once the event is dispatched to the view, it's up to that View whether or not to change the state of itself. Idk if there are any special checks for view state updates to see if it's visible or not (unless this is done explicitly in your custom views) I'm mostly leaning towards there aren't any such checks. So, once the view is visible again it will reflect the last emitted state from the LiveData.
Could be a whole different story with jetpack compose though. I am not 100% sure if recomposition in jetpack compose ignores the state update from models (top to bottom), if the element is added to the UI tree and is not visible (I'm not even sure if that's possible in compose) But since you're specifically asking about the traditional views, this is least of your concern.
s
Thanks @Kedar
👍 1