jvmTest.util.FakeEventSource.kt Maven / Gradle / Ivy
package kt.mobius
import kt.mobius.disposables.Disposable
import kt.mobius.functions.Consumer
import java.util.ArrayList
internal class FakeEventSource : EventSource {
private val myConsumers = ArrayList>()
fun emit(toEmit: E) {
for (myConsumer in myConsumers) {
myConsumer.accept(toEmit)
}
}
override fun subscribe(eventConsumer: Consumer): Disposable {
myConsumers.add(eventConsumer)
return object : Disposable {
override fun dispose() {
// no-op for now; add a 'disposed' flag or something if needed later
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy