viewBinder

inline fun <ModelT, BindDataT : Any> Style.viewBinder(binder: RenderUnit.Binder<ModelT, View, BindDataT>, model: ModelT): Style

Creates a Style which will apply the given RenderUnit.Binder to the View rendered by the Component the Style is added to. This abstraction can be used to create higher-level Styles which can apply some property generically to any type of Component.

The usage of this binder will guarantee that there will be an associated View to it by calling Style.wrapInView.

Notes for implementing a RenderUnit.Binder:

The binder's RenderUnit.Binder.bind will be called by the framework with the current model to bind the model to the View content, and RenderUnit.Binder.unbind will be called with the current model to unbind the model from the View content. When the model changes in a new render pass, RenderUnit.Binder.shouldUpdate will be called with the old and new models before unbind/bind: if it returns true, unbind(oldModel)+bind(newModel) will be called. Otherwise, the update will be skipped.

In some cases, you may want your binder's bind to be called only the first time the content is mounted, and unbind called the last time it is unmounted before going offscreen. In that case, you can unconditionally return false from RenderUnit.Binder.shouldUpdate.

Generally speaking, a RenderUnit.Binder should be static and unchanging, while the model may change between renders.

Parameters

binder

the RenderUnit.Binder to be used to bind the model to the View content.

model

the current model to bind.


inline fun <BindDataT : Any> Style.viewBinder(binder: RenderUnit.Binder<Unit, View, BindDataT>): Style

An overload of Style.viewBinder which takes a RenderUnit.Binder that does not require a model.

Parameters

binder

the RenderUnit.Binder to be used to bind the model to the View content.


fun Style.viewBinder(binder: RenderUnit.DelegateBinder<*, View, Any>): Style

Deprecated

use parameterized viewBinder methods above