Skip to content

Commit

Permalink
returned immediately binding
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunkov_A@utkonos.ru authored and Lunkov_A@utkonos.ru committed Jun 17, 2020
1 parent 64a10ea commit 0d9ef7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ interface Component<C, VM : ComponentViewModel> {
}
}

fun render(attachToContainer: Boolean = true): ViewDataBinding? =
renderer.render(scheme.getBindingClass?.invoke(this as C, viewModel), attachToContainer)
fun render(immediately: Boolean = true): ViewDataBinding? =
renderer.render(scheme.getBindingClass?.invoke(this as C, viewModel), immediately)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ class Renderer(private val component: Component<*, *>) {

fun render(
newBindingClass: KClass<out ViewDataBinding>?,
attachToContainer: Boolean
immediately: Boolean
): ViewDataBinding? {
currentBinding?.let {
if (newBindingClass != null && newBindingClass == currentBindingClass) {
it.setViewModel(component.viewModel)
if (immediately) it.executePendingBindings()
return it
}
(component.container as? ViewGroup)?.removeAllViews()
Expand All @@ -26,8 +27,8 @@ class Renderer(private val component: Component<*, *>) {
?: throw UnsupportedOperationException("Component must be ViewGroup"),
component.viewModel,
component.boundLifecycleOwner,
attachToContainer
)
immediately
)?.apply { if (immediately) executePendingBindings() }
currentBindingClass = newBindingClass
return currentBinding
}
Expand Down

0 comments on commit 0d9ef7a

Please sign in to comment.