All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.cedrickring.reactormongodb.collection.flux.MapReduceFlux.kt Maven / Gradle / Ivy

package com.github.cedrickring.reactormongodb.collection.flux

import com.github.cedrickring.reactormongodb.collection.ReactiveCollection
import reactor.core.CoreSubscriber
import reactor.core.publisher.Flux

class MapReduceFlux(private val reactiveCollection: ReactiveCollection,
                               private val mapFunction: String,
                               private val reduceFunction: String,
                               private val resultClass: Class) : Flux() {

    override fun subscribe(actual: CoreSubscriber?) {
        reactiveCollection.nativeCollection.mapReduce(mapFunction, reduceFunction, resultClass)
                .forEach(
                        { result -> actual?.onNext(result) },
                        { _, throwable -> if (throwable != null) actual?.onError(throwable) }
                )
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy