Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
Rene Dohan committed Jan 14, 2025
1 parent 0ff63b9 commit d4fa188
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,17 @@ fun CSHasChangeValue<Boolean>.actionFalse(function: () -> Unit): CSRegistration
return onFalse(function)
}

operator fun CSHasChangeValue<Boolean>.not() = delegate(from = { !it })
operator fun CSHasChangeValue<Boolean>.not() = delegate(from = { !it })

fun CSHasChangeValue<Boolean>.onTrueUntilFalse(
registration: () -> CSRegistration?): CSRegistration =
actionTrue { untilFalse(registration()) }

fun CSHasChangeValue<Boolean>.untilFalse(
registration: CSRegistration): CSRegistration =
onFalse { registration.cancel() }

@JvmName("untilFalseCSRegistrationNullable")
fun CSHasChangeValue<Boolean>.untilFalse(
registration: CSRegistration?): CSRegistration? =
registration?.let(::untilFalse)

0 comments on commit d4fa188

Please sign in to comment.