handling state mutation on reactive programming project reactor

Viewed 149

i have a question regarding updating mutable state on reactive streams. I found the following code:

Mono<Transaction> closeTransaction(Long id) {
return transactionRepository.findById(1L)
.map(transaction -> transaction.setStatus("DONE")
.flatMap(transactionRepository::save);
}

Then, reading some books on functional and reactive programming, i have found that they suggest not mutating data state or doing some side effects activities on reactive primitives such as map. However i have found lot of reactive code written like above code. How should we handle state mutation on reactive frameworks? I'm woking on Java projects with project reactor and it is not clear which primitives should handle with mutable state and which shouldn't.

Thanks, Jorge

0 Answers
Related