Kazemihabib1996
05/13/2020, 2:26 PMstaticAmbientOf
instead of ambientOf
? what's the benefit of using staticAmbientOf
that RippleTheme
for example uses that instead of ambientOf
?Adam Powell
05/13/2020, 2:37 PMstaticAmbientOf
has lower overhead but if it ever changes in place, we will invalidate and recompose the entire subhierarchy below the Providers
where it changed, since we don't track precise location of reads for static ambients.State<T>
that holds the "real" value of the ambientState<T>
instance from the Providers
in the composition stays constant and never changes, only the observable value changes when you provide a new value for the ambient key.Kazemihabib1996
05/13/2020, 2:47 PMstaticAmbientOf
for RippleTheme
as in most applications developers set that one time and won't change it later?Chuck Jazdzewski [G]
05/13/2020, 4:39 PMstaticAmbientOf
for ambients that are unlikely to ever change or if they do change they likely invalidate the entire tree anyway. Here, change is defined as changing the value provided at the point it is provided. If a static ambient is re-provided, it is not counted as being changed and will not invalidate the tree below it, the tree below just sees a different value than the tree above.