Remove unnecessary result parameter in interactor

This commit is contained in:
Moez Bhatti
2018-03-05 16:37:09 -05:00
parent f9ad73ab11
commit 89b68672a2
22 changed files with 28 additions and 26 deletions
@@ -24,7 +24,7 @@ import timber.log.Timber
import java.util.concurrent.TimeUnit
import javax.inject.Inject
open class ContactSync @Inject constructor(private val syncManager: SyncManager) : Interactor<Unit, Long>() {
open class ContactSync @Inject constructor(private val syncManager: SyncManager) : Interactor<Unit>() {
override fun buildObservable(params: Unit): Flowable<Long> {
return Flowable.just(System.currentTimeMillis())
@@ -22,7 +22,7 @@ import data.repository.MessageRepository
import io.reactivex.Flowable
import javax.inject.Inject
class DeleteConversation @Inject constructor(private val messageRepo: MessageRepository): Interactor<Long, Unit>() {
class DeleteConversation @Inject constructor(private val messageRepo: MessageRepository): Interactor<Long>() {
override fun buildObservable(params: Long): Flowable<Unit> {
return Flowable.just(Unit)
@@ -22,7 +22,7 @@ import data.repository.MessageRepository
import io.reactivex.Flowable
import javax.inject.Inject
class DeleteMessage @Inject constructor(private val messageRepository: MessageRepository): Interactor<Long, Long>() {
class DeleteMessage @Inject constructor(private val messageRepository: MessageRepository): Interactor<Long>() {
override fun buildObservable(params: Long): Flowable<Long> {
return Flowable.just(params)
+1 -1
View File
@@ -28,7 +28,7 @@ import javax.inject.Inject
class FullSync @Inject constructor(
private val syncManager: SyncManager,
private val keys: Keys
) : Interactor<Unit, Long>() {
) : Interactor<Unit>() {
override fun buildObservable(params: Unit): Flowable<Long> {
return Flowable.just(System.currentTimeMillis())
+7 -5
View File
@@ -22,19 +22,21 @@ import io.reactivex.Flowable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable
import io.reactivex.rxkotlin.plusAssign
import io.reactivex.schedulers.Schedulers
abstract class Interactor<in Params, Result>: Disposable {
abstract class Interactor<in Params>: Disposable {
private val disposables: CompositeDisposable = CompositeDisposable()
abstract fun buildObservable(params: Params): Flowable<Result>
abstract fun buildObservable(params: Params): Flowable<*>
fun execute(params: Params, observer: (Result) -> Unit = {}) {
disposables.add(buildObservable(params)
fun execute(params: Params, onComplete: () -> Unit = {}) {
disposables += buildObservable(params)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(observer))
.doOnComplete(onComplete)
.subscribe()
}
override fun dispose() {
@@ -22,7 +22,7 @@ import data.repository.MessageRepository
import io.reactivex.Flowable
import javax.inject.Inject
class MarkAllSeen @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Unit, Unit>() {
class MarkAllSeen @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Unit>() {
override fun buildObservable(params: Unit): Flowable<Unit> {
return Flowable.just(Unit)
@@ -22,7 +22,7 @@ import data.repository.MessageRepository
import io.reactivex.Flowable
import javax.inject.Inject
class MarkArchived @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long, Unit>() {
class MarkArchived @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long>() {
override fun buildObservable(params: Long): Flowable<Unit> {
return Flowable.just(Unit)
@@ -22,7 +22,7 @@ import data.repository.MessageRepository
import io.reactivex.Flowable
import javax.inject.Inject
class MarkBlocked @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long, Unit>() {
class MarkBlocked @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long>() {
override fun buildObservable(params: Long): Flowable<Unit> {
return Flowable.just(Unit)
@@ -22,7 +22,7 @@ import data.repository.MessageRepository
import io.reactivex.Flowable
import javax.inject.Inject
class MarkDelivered @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long, Unit>() {
class MarkDelivered @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long>() {
override fun buildObservable(params: Long): Flowable<Unit> {
return Flowable.just(Unit)
@@ -24,7 +24,7 @@ import javax.inject.Inject
class MarkDeliveryFailed @Inject constructor(
private val messageRepo: MessageRepository)
: Interactor<MarkDeliveryFailed.Params, Unit>() {
: Interactor<MarkDeliveryFailed.Params>() {
data class Params(val id: Long, val resultCode: Int)
+1 -1
View File
@@ -26,7 +26,7 @@ import javax.inject.Inject
class MarkFailed @Inject constructor(
private val messageRepo: MessageRepository,
private val notificationManager: NotificationManager
) : Interactor<MarkFailed.Params, Unit>() {
) : Interactor<MarkFailed.Params>() {
data class Params(val id: Long, val resultCode: Int)
+1 -1
View File
@@ -26,7 +26,7 @@ import javax.inject.Inject
class MarkRead @Inject constructor(
private val messageRepo: MessageRepository,
private val notificationManager: NotificationManager
) : Interactor<Long, Unit>() {
) : Interactor<Long>() {
override fun buildObservable(params: Long): Flowable<Unit> {
return Flowable.just(Unit)
+1 -1
View File
@@ -22,7 +22,7 @@ import data.repository.MessageRepository
import io.reactivex.Flowable
import javax.inject.Inject
class MarkSeen @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long, Unit>() {
class MarkSeen @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long>() {
override fun buildObservable(params: Long): Flowable<Unit> {
return Flowable.just(Unit)
+1 -1
View File
@@ -22,7 +22,7 @@ import data.repository.MessageRepository
import io.reactivex.Flowable
import javax.inject.Inject
class MarkSent @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long, Unit>() {
class MarkSent @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long>() {
override fun buildObservable(params: Long): Flowable<Unit> {
return Flowable.just(Unit)
@@ -22,7 +22,7 @@ import data.repository.MessageRepository
import io.reactivex.Flowable
import javax.inject.Inject
class MarkUnarchived @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long, Unit>() {
class MarkUnarchived @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long>() {
override fun buildObservable(params: Long): Flowable<Unit> {
return Flowable.just(Unit)
@@ -22,7 +22,7 @@ import data.repository.MessageRepository
import io.reactivex.Flowable
import javax.inject.Inject
class MarkUnblocked @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long, Unit>() {
class MarkUnblocked @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long>() {
override fun buildObservable(params: Long): Flowable<Unit> {
return Flowable.just(Unit)
@@ -28,7 +28,7 @@ import javax.inject.Inject
open class PartialSync @Inject constructor(
private val syncManager: SyncManager,
private val permissions: Permissions
) : Interactor<Unit, Long>() {
) : Interactor<Unit>() {
override fun buildObservable(params: Unit): Flowable<Long> {
return Flowable.just(System.currentTimeMillis())
+1 -1
View File
@@ -31,7 +31,7 @@ class ReceiveMms @Inject constructor(
private val syncManager: SyncManager,
private val messageRepo: MessageRepository,
private val notificationManager: NotificationManager
) : Interactor<Uri, Conversation>() {
) : Interactor<Uri>() {
override fun buildObservable(params: Uri): Flowable<Conversation> {
return Flowable.just(params)
+1 -1
View File
@@ -29,7 +29,7 @@ import javax.inject.Inject
class ReceiveSms @Inject constructor(
private val messageRepo: MessageRepository,
private val notificationManager: NotificationManager)
: Interactor<Array<SmsMessage>, Conversation>() {
: Interactor<Array<SmsMessage>>() {
override fun buildObservable(params: Array<SmsMessage>): Flowable<Conversation> {
return Flowable.just(params)
@@ -23,7 +23,7 @@ import data.repository.MessageRepository
import io.reactivex.Flowable
import javax.inject.Inject
class RetrySending @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Message, Message>() {
class RetrySending @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Message>() {
override fun buildObservable(params: Message): Flowable<Message> {
@@ -35,7 +35,7 @@ class SendMessage @Inject constructor(
private val context: Context,
private val prefs: Preferences,
private val messageRepo: MessageRepository
) : Interactor<SendMessage.Params, Unit>() {
) : Interactor<SendMessage.Params>() {
data class Params(val threadId: Long, val addresses: List<String>, val body: String, val attachments: List<Uri> = listOf())
@@ -28,7 +28,7 @@ import javax.inject.Inject
class SyncMessage @Inject constructor(
private val syncManager: SyncManager,
private val messageRepo: MessageRepository
) : Interactor<Uri, Message>() {
) : Interactor<Uri>() {
override fun buildObservable(params: Uri): Flowable<Message> {
return Flowable.just(params)