Hello I am pretty new to Functional Programming of...
# functional
k
Hello I am pretty new to Functional Programming of Kotlin. I am currently using Reactor for my project It is difficult to work in streams because once the instances of the stream changes it form, I can’t use the instances before change. ex) • Flux<AClass> -> Flux<BClass> -> SomeFunction that needs instances of AClass If above situation happens, I had to find AClass instances again, so the stream would go like • Flux<AClass> -> Flux<BClass> -> Flux<AClass> which I think is redundant and DB-work-expensive So I came up with this Idea to store the value of AClass, and then use it later without getting back.
Copy code
fun someFunction(something: Foo): Mono<Foo> {
        var zoo: Foo = Foo();

        fooRepository.find()
                .doOnNext { zoo = functionThatReturnsZoo() } // change the value of zoo
                .flatMap { ... }
                .flatMap { fooRepository.save(zoo) } // use zoo
    }