Skip to content

Commit 0d9ef7a

Browse files
Lunkov_A@utkonos.ruLunkov_A@utkonos.ru
authored andcommitted
returned immediately binding
1 parent 64a10ea commit 0d9ef7a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

ui-generator-base/src/main/java/ru/impression/ui_generator_base/Component.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ interface Component<C, VM : ComponentViewModel> {
5353
}
5454
}
5555

56-
fun render(attachToContainer: Boolean = true): ViewDataBinding? =
57-
renderer.render(scheme.getBindingClass?.invoke(this as C, viewModel), attachToContainer)
56+
fun render(immediately: Boolean = true): ViewDataBinding? =
57+
renderer.render(scheme.getBindingClass?.invoke(this as C, viewModel), immediately)
5858
}

ui-generator-base/src/main/java/ru/impression/ui_generator_base/Renderer.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ class Renderer(private val component: Component<*, *>) {
1212

1313
fun render(
1414
newBindingClass: KClass<out ViewDataBinding>?,
15-
attachToContainer: Boolean
15+
immediately: Boolean
1616
): ViewDataBinding? {
1717
currentBinding?.let {
1818
if (newBindingClass != null && newBindingClass == currentBindingClass) {
1919
it.setViewModel(component.viewModel)
20+
if (immediately) it.executePendingBindings()
2021
return it
2122
}
2223
(component.container as? ViewGroup)?.removeAllViews()
@@ -26,8 +27,8 @@ class Renderer(private val component: Component<*, *>) {
2627
?: throw UnsupportedOperationException("Component must be ViewGroup"),
2728
component.viewModel,
2829
component.boundLifecycleOwner,
29-
attachToContainer
30-
)
30+
immediately
31+
)?.apply { if (immediately) executePendingBindings() }
3132
currentBindingClass = newBindingClass
3233
return currentBinding
3334
}

0 commit comments

Comments
 (0)