Reputation: 33
One of my colleagues said to me that instead of processing streams i should create a Flux instead of using a List as it is and then Process my data to it.
But this doesn't makes sense to me because i thought reactive streams were generally useful for blocking io not data processing .
Can someone verify if the new approach suggested by my colleague is correct. and if it is correct, what are the advantages of it over my previous method(performance wise)
//Model
rootObject{
List<rootNodes> rootNodes
}
//My current code
MonoOfRootObject.map( rootobject.getrootnodes.stream()
.(..do some filtering and replacement..) )
//Proposed code according to my colleague
MonoOfRootObject.map( Flux.fromIterable(rootobject.getrootnodes)
.(..do some filtering and replacement..) )
Please help i am a bit new to Reactor (or functional programming in general)
Thanks
Upvotes: 0
Views: 1573
Reputation: 9947
Yes, you're right. Reactor and Reactive Streams in general are useful when you need to deal with asynchronous data and/or concurrency.
To do regular filtering, transformation on an in-memory list, Java Stream is totally fine and using Reactive Stream is overkill (and probably also overhead performance wise).
Upvotes: 3