title: Get the sum of a map in Reactor Mono
body: <p>How do I add up all the results of a Mono/Flux</p>
  <p>I have some reactive code where i return a Flux and chain some other functions, I will explain it with some code.</p>
  <pre><code>return commentService.getAllCommentByIssueId(issueId)
                  .map {
                      taggingService.tagging(it.content).map {
                          //Get the count of the returned set and add it up to 
                          //all the other returned map results
                          //So the result should be like
                          //tags in first comment 2, tags in second comment 3
                          //so it should return 5
                      }
  </code></pre>
  <p>So I return a Flux, it is a Flux of Comments. I want to map all the comments of this query, to a function where I scan the content of each comment for tags, this is implemented by the <code>taggingservice.tagging</code>, that function returns a <code>Mono&lt;MutableSet&lt;UUID&gt;&gt;</code> so it returns all the UUIDs which got tagged.
  An issue has a x number of comments, I want to sum up all the tags in all comments.</p>
  <p>What I want to do is to count up all the tags of each comment of an issue and return it in a StatsModel which consists of <code>StatsModel(issueId,numberOfTagsInComments)</code></p>
  <p>I will show you now the tagging function:</p>
  <p>(I tested the function, it is working)</p>
  <pre><code>fun tagging(text:String) : Mono&lt;MutableSet&lt;UUID&gt;&gt; {
          val words = text.split( &quot; &quot;)
                  .filter { it.startsWith(&quot;@&quot;)}
          val matches : MutableSet&lt;UUID&gt; = mutableSetOf()
  
          return userRepository.findAll().collectList()
                  .map { userList -&gt;
                      for(word in words){
                          userList.map {user -&gt;
                              if(user.username == word.substring(1)) {
                                  matches.add(user.id!!)
                              }
                          }
                      }
                      matches
                  }
      }
  </code></pre>
  <p>And my CommentRepository, I am using the first function fo this repo.</p>
  <pre><code>@Repository
  interface CommentRepository: ReactiveCrudRepository&lt;CommentModel, UUID&gt; {
      fun findAllByIssueId(issueId: UUID): Flux&lt;CommentModel&gt;
      fun findAllByUserId(userId: UUID): Flux&lt;CommentModel&gt;
  }
  </code></pre>