mirror of
https://github.com/InsanusMokrassar/PsychomatrixBase.git
synced 2024-11-15 04:43:58 +00:00
fix notification about psychomatrix changes
This commit is contained in:
parent
25e24db57c
commit
f436cf2e9f
@ -8,6 +8,7 @@ import com.github.insanusmokrassar.PsychomatrixBase.domain.entities.operations.O
|
|||||||
import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.SUBSCRIPTIONS_MEDIUM
|
import com.github.insanusmokrassar.PsychomatrixBase.utils.extensions.SUBSCRIPTIONS_MEDIUM
|
||||||
import kotlinx.coroutines.experimental.channels.BroadcastChannel
|
import kotlinx.coroutines.experimental.channels.BroadcastChannel
|
||||||
import kotlinx.coroutines.experimental.channels.ReceiveChannel
|
import kotlinx.coroutines.experimental.channels.ReceiveChannel
|
||||||
|
import kotlinx.coroutines.experimental.launch
|
||||||
|
|
||||||
class ModifyPsychomatrixUseCaseInteractor : ModifyPsychomatrixUseCase {
|
class ModifyPsychomatrixUseCaseInteractor : ModifyPsychomatrixUseCase {
|
||||||
private val currentPsychomatrixes: MutableList<MutablePsychomatrix> = ArrayList()
|
private val currentPsychomatrixes: MutableList<MutablePsychomatrix> = ArrayList()
|
||||||
@ -19,11 +20,21 @@ class ModifyPsychomatrixUseCaseInteractor : ModifyPsychomatrixUseCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun makeConvert(psychomatrix: MutablePsychomatrix, operation: Operation): Boolean {
|
override fun makeConvert(psychomatrix: MutablePsychomatrix, operation: Operation): Boolean {
|
||||||
return asMutablePsychomatrix(psychomatrix).applyConvert(operation)
|
return asMutablePsychomatrix(psychomatrix).applyConvert(operation).also {
|
||||||
|
if (it) {
|
||||||
|
launch {
|
||||||
|
psychomatrixChangedBroadcastChannel.send(psychomatrix to (operation to true))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun makeInvert(psychomatrix: MutablePsychomatrix, operation: Operation): Boolean {
|
override fun makeInvert(psychomatrix: MutablePsychomatrix, operation: Operation): Boolean {
|
||||||
return asMutablePsychomatrix(psychomatrix).applyInvert(operation)
|
return asMutablePsychomatrix(psychomatrix).applyInvert(operation).also {
|
||||||
|
launch {
|
||||||
|
psychomatrixChangedBroadcastChannel.send(psychomatrix to (operation to false))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getConverts(psychomatrix: Psychomatrix): List<Operation> {
|
override fun getConverts(psychomatrix: Psychomatrix): List<Operation> {
|
||||||
|
Loading…
Reference in New Issue
Block a user