rxdart icon indicating copy to clipboard operation
rxdart copied to clipboard

Operator groupBy produces Streams with incorrect behavior

Open NaikSoftware opened this issue 3 years ago • 6 comments

Code below works fine

.groupBy((event) => event.type)
.flatMap((groupByType) => groupByType.toSet().asStream())

But if you change to this - onNext never called because of groupByType.toSet() never completes

.groupBy((event) => event.type)
.asyncMap((groupByType) => groupByType.toSet())

rxdart: ^0.26.0

NaikSoftware avatar Apr 14 '21 13:04 NaikSoftware

That is expected behavior

hoc081098 avatar Apr 16 '21 04:04 hoc081098

You can use scan((acc, e) => {...acc!, e}, <Object>{}) instead toSet()

hoc081098 avatar Apr 16 '21 04:04 hoc081098

@hoc081098 can you explain why this is expected behaviour?

NaikSoftware avatar Aug 11 '21 16:08 NaikSoftware

@hoc081098 can you explain why this is expected behaviour?

Each group will complete when upstream (source stream) completes.

hoc081098 avatar Aug 11 '21 16:08 hoc081098

@hoc081098 Where I said what upstream never completes?) It just a stream from list.

NaikSoftware avatar Aug 11 '21 16:08 NaikSoftware

@hoc081098 Where I said what upstream never completes?) It just a stream from list.

Could you provide some code to reproduce this issue? Thanks

hoc081098 avatar Sep 03 '21 20:09 hoc081098