This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface SchedulerProvider { | |
fun computation(): Scheduler | |
fun io(): Scheduler | |
fun ui(): Scheduler | |
fun single(): Scheduler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainController { | |
fun getItems() : List<Item> { | |
val apiResponse = getItemsFromApi() | |
val dbResponse = getItemsFromDb() | |
return Observable.concatArray(getItemsFromDb().toObservable(), getItemsFromApi().toObservable()) | |
.onErrorReturn { | |
listOf() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.LocalDateTime | |
class Boy { | |
infix fun name(name : String) { | |
println("His name is $name") | |
} | |
} | |
fun main(args : Array<String>) { | |
val boy = Boy() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.github.pwittchen.reactivenetwork.library.rx2.Connectivity | |
import io.reactivex.Completable | |
import io.reactivex.Flowable | |
import io.reactivex.FlowableTransformer | |
import io.reactivex.Observable | |
import com.rv.user.networkerrorretrier.Result | |
interface NetworkManager { | |
/** | |
* Exception used to denote that an operation was performed when network was not available. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eventBus.observeEventOnUi<EventTypeOne>() | |
.map { //Do any transformation if you want to! Bonus! } | |
.subscribe { | |
// Subscriber | |
} | |
eventBus.observeEventOnUi<EventTypeTwo>() | |
.subscribe { | |
// Subscriber | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* [EventBus] implementation backed by a [PublishProcessor] | |
*/ | |
class RxBus : EventBus { | |
private val publishProcessor = PublishProcessor.create<Any>() | |
override fun postEvent(event: Any) { | |
publishProcessor.onNext(event) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Events are posted to common bus and all active subscribers are notified of changes. Threading and | |
* backpresssure can be handled by subscribers. | |
*/ | |
interface EventBus { | |
/** | |
* Post an event to bus. | |
*/ | |
fun postEvent(event: Any) |