Skip to content

Commit

Permalink
added immediately binding option
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 08fc5c8 commit 8cd431a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ interface Component<C, VM : ComponentViewModel> {
}
}

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

var currentBindingClass: KClass<out ViewDataBinding>? = null

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

0 comments on commit 8cd431a

Please sign in to comment.