Hi guys, im having some trouble undesrtanding the ...
# getting-started
c
Hi guys, im having some trouble undesrtanding the following method in Kotlin.
Copy code
/**
 * Use backpressure to ensure only next item doesn't arrive until the current one has been processed.
 * Intended for onClicks that trigger API calls
 */
fun <T> Observable<T>.oneAtATime(next:(t: T, more:()->Unit)->Unit) {
    onBackpressureDrop().subscribe(object : Subscriber<T>() {
        override fun onStart() = request(1)

        override fun onNext(t: T) {
            next(t) {
                request(1)
            }
        }

        override fun onCompleted() { }

        override fun onError(e: Throwable?) { }

    })
}