He-Pin commented on code in PR #1870:
URL: https://github.com/apache/pekko/pull/1870#discussion_r2106189771


##########
stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/FlowStatefulMapConcatSpec.scala:
##########
@@ -99,6 +99,37 @@ class FlowStatefulMapConcatSpec extends StreamSpec("""
         .expectComplete()
     }
 
+    "be able to handle onComplete signal" in {
+      Source(List(1, 2, 3, 4, 5))
+        // grouped 2
+        .statefulMapConcat(() =>
+          new StatefulMapConcatAccumulator[Int, Int] {
+            private var count = 0
+            private val buffer = List.newBuilder[Int]
+            override def apply(elem: Int): IterableOnce[Int] = {
+              buffer.addOne(elem)
+              count += 1
+              if (count < 2) {
+                Nil
+              } else {
+                val result = buffer.result()
+                buffer.clear()
+                count = 0
+                result
+              }
+            }
+            override def onComplete(): IterableOnce[Int] = {
+              val result = buffer.result()
+              buffer.clear()
+              result

Review Comment:
   We can see, the `5` is not lost, because of the `onComplete` callback.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org
For additional commands, e-mail: notifications-h...@pekko.apache.org

Reply via email to