From 6be9367e63b5a5db325cde97e74b431eb4e8341e Mon Sep 17 00:00:00 2001 From: Rene Dohan Date: Sun, 5 May 2024 23:49:37 +0800 Subject: [PATCH] ... --- .../renetik/android/event/registration/CSHasChangeValue+.kt | 6 +++--- .../renetik/android/event/registration/CSHasChangeValue.kt | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/library/src/main/java/renetik/android/event/registration/CSHasChangeValue+.kt b/library/src/main/java/renetik/android/event/registration/CSHasChangeValue+.kt index 30b2bb4..66fb166 100644 --- a/library/src/main/java/renetik/android/event/registration/CSHasChangeValue+.kt +++ b/library/src/main/java/renetik/android/event/registration/CSHasChangeValue+.kt @@ -187,14 +187,14 @@ inline fun CSHasChangeValue.action( }) } -inline fun CSHasChangeValue.actionNullable( - crossinline child: (ParentValue) -> CSHasChangeValue?, +inline fun CSHasChangeValue.action( + crossinline optionalChild: (ParentValue) -> CSHasChangeValue?, crossinline onChange: ((ChildValue?) -> Unit) ): CSRegistration { var childRegistration: CSRegistration? = null val parentRegistration = action { parentValue -> childRegistration?.cancel() - childRegistration = child(parentValue)?.let { + childRegistration = optionalChild(parentValue)?.let { it.action { childValue -> onChange(childValue) } } ?: run { onChange(null); null } } diff --git a/library/src/main/java/renetik/android/event/registration/CSHasChangeValue.kt b/library/src/main/java/renetik/android/event/registration/CSHasChangeValue.kt index c17e1ca..c420848 100644 --- a/library/src/main/java/renetik/android/event/registration/CSHasChangeValue.kt +++ b/library/src/main/java/renetik/android/event/registration/CSHasChangeValue.kt @@ -209,8 +209,8 @@ interface CSHasChangeValue : CSValue, CSHasChange { ): CSHasChangeValue { val event = event() var value: ChildValue? = null - actionNullable( - child = { child(it) }, + action( + optionalChild = { child(it) }, onChange = { value = it onChange?.invoke(value)