You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A zero-cost wrapper which acts like Property<T> | T.
// pseudokode, won't kompileinlineclassPropertyOrValue<T> {
privateval_value:Any?// = Property<T> | Tconstructor(value:T) {
this._value=// guard against the (rare) case when value is also a property:if (value isProperty<*>) immutablePropertyOf(value)
else value
}
constructor(property:Property<T>) {
this._value= property
}
val value:T
get() = (if (_valueisProperty<*>) _value.value else_value) asT// TODO: addChangeListener(On), removeChangeListener
}
Use-cases:
universal [library] components which accept some Properties may accept PropertyOfValue instead, allowing caller to avoid wrapping value into ImmutableProperty
Android resources: (typedValue.changingConfigurations & activityInfo.configChanges) == 0 implies Value, else Property (not sure how popular this case is, taking into account that resources are good at storing strings, but other resource types — animations and animators, drawables, colours and colour state lists, layouts, menus, styles, fonts, scalars and scalar arrays — are mostly useless)
The text was updated successfully, but these errors were encountered:
A zero-cost wrapper which acts like
Property<T> | T
.Use-cases:
ImmutableProperty
(typedValue.changingConfigurations & activityInfo.configChanges) == 0
implies Value, else Property (not sure how popular this case is, taking into account that resources are good at storing strings, but other resource types — animations and animators, drawables, colours and colour state lists, layouts, menus, styles, fonts, scalars and scalar arrays — are mostly useless)The text was updated successfully, but these errors were encountered: