KyooSik Lee
12/11/2019, 9:20 AMfun 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
}
Will this be functional too?Boris Dudelsack
12/11/2019, 9:25 AMreturn Mono.fromCallable(functionThatReturnsZoo() }
.flatMap { ... }
.doOnNext { fooRepository.save(it) }
KyooSik Lee
12/11/2019, 9:37 AMBoris Dudelsack
12/11/2019, 9:45 AMmap
method. You can then change one object to another. Like:
fooRepository.find()
.map { functionThatReturnsZoo(it) }
.map { doSomethingElesWithIt(it) }
Pair
or some custom class
fooRepository.find()
.map { Pair(it, functionThatReturnsZoo(it)) }
.map { Pair(it.first, doSomethingElse(it.second) }
KyooSik Lee
12/13/2019, 7:45 AMfooRepository.find()
.map { Pair(it, functionThatReturnsZoo(it)) }
.map { Pair(it.first, doSomethingElse(it.second)
.map { Pair(it.first, doSomethingElse(it.second) }
.map { Pair(it.first, doSomethingElse(it.second) }
}
Do I have to carry until the end?Boris Dudelsack
12/13/2019, 8:03 AM