Skip to content

Commit

Permalink
remove optional name misuse...
Browse files Browse the repository at this point in the history
  • Loading branch information
renetik committed Jun 27, 2024
1 parent 4c86de3 commit 55d0cd9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ inline fun <ParentValue, ChildValue> CSHasChangeValue<ParentValue>.action(
}

inline fun <ParentValue, ChildValue> CSHasChangeValue<ParentValue>.action(
crossinline optionalChild: (ParentValue) -> CSHasChangeValue<ChildValue>?,
crossinline nullableChild: (ParentValue) -> CSHasChangeValue<ChildValue>?,
crossinline onChange: ((ChildValue?) -> Unit)
): CSRegistration {
var childRegistration: CSRegistration? = null
val parentRegistration = action { parentValue ->
childRegistration?.cancel()
childRegistration = optionalChild(parentValue)?.let {
childRegistration = nullableChild(parentValue)?.let {
it.action { childValue -> onChange(childValue) }
} ?: run { onChange(null); null }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import renetik.android.core.lang.value.CSValue
import renetik.android.event.common.CSHasDestruct
import renetik.android.event.common.destruct
import renetik.android.event.property.CSPropertyBase
import renetik.android.event.registration.CSRegistration.Companion.CSRegistration
import kotlin.properties.Delegates.notNull

interface CSHasChangeValue<T> : CSValue<T>, CSHasChange<T> {
Expand Down Expand Up @@ -220,7 +219,7 @@ interface CSHasChangeValue<T> : CSValue<T>, CSHasChange<T> {

init {
this + property.action(
optionalChild = { child(it) },
nullableChild = { child(it) },
onChange = { value(it) }
)
}
Expand Down

0 comments on commit 55d0cd9

Please sign in to comment.