August 2017
Intermediate to advanced
440 pages
10h
English
Operator overloading is a big Kotlin feature, but we often need to use Java libraries and operators that are not defined there. For example, in RxJava, we use the CompositeDisposable function to manage subscriptions. This collection uses the add method to add new elements. This is an example subscription added to CompositeDisposable:
val subscriptions = CompositeDisposable()
subscriptions.add(repository
.getAllCharacters(qualifiedSearchQuery)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::charactersLoaded, view::showError))
The standard Kotlin way to add a new element to a mutable collection is by using the plusAssign operator (+=). It is not only ...
Read now
Unlock full access