File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed
src/main/java/com/alexdeww/reactiveviewmodel/core/property Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ afterEvaluate {
4444 release(MavenPublication ) {
4545 from components. release
4646 groupId = ' com.alexdeww.reactiveviewmodel'
47- version = ' 2.3.9 '
47+ version = ' 2.4.0 '
4848 }
4949 }
5050 }
Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ class ConfirmationEvent<T : Any> internal constructor(debounceInterval: Long? =
1616 private sealed class EventType {
1717 data class Pending (val data : Any ) : EventType()
1818 object Confirmed : EventType()
19+
20+ @Suppress(" UNCHECKED_CAST" )
21+ fun <T > tryGetData (): T ? = if (this is Pending ) data as T else null
1922 }
2023
2124 private val eventState = State <EventType >(EventType .Confirmed , debounceInterval)
@@ -69,7 +72,7 @@ class ConfirmationEvent<T : Any> internal constructor(debounceInterval: Long? =
6972 @Suppress(" UNCHECKED_CAST" )
7073 override fun onActive () {
7174 super .onActive()
72- addSource(eventState.liveData) { value = (it as ? EventType . Pending )?.data as T }
75+ addSource(eventState.liveData) { value = it.tryGetData< T >() }
7376 }
7477
7578 override fun onInactive () {
You can’t perform that action at this time.
0 commit comments