I'm new to WebFlux/Reactor and having trouble wrapping my head around how to write this piece of code. Basically, I have a Flux which has a nested List foo and a Mono<Set> bar and I'd like to only return items in foo that are contained in bar.
// these two lines are representations of what the data looks like
Flux<CategoryModel> foo = { Permissions = [ "UserRole1"] } // List<String>
Mono<Set<String>> bar = [ "UserRole1", "UserRole2" ];
var filteredFoo = foo.filter(m -> m.getPermissions().stream().anyMatch(perm -> bar.block().contains(foo)));
The problem with the above block of code is the .block()
on the contains()
and I don't want to block. Not sure how to change this to have non blocking but still check if bar contains the perm item.