top of page

๐Ÿค” Do you know the difference between an upstream and a downstream flow in Kotlin coroutines?




If you go looking through flow documentation in coroutines, you will eventually run into something like this:


๐˜๐˜ฏ ๐˜ฑ๐˜ข๐˜ณ๐˜ต๐˜ช๐˜ค๐˜ถ๐˜ญ๐˜ข๐˜ณ, ๐˜ต๐˜ฉ๐˜ช๐˜ด ๐˜ฐ๐˜ฑ๐˜ฆ๐˜ณ๐˜ข๐˜ต๐˜ฐ๐˜ณ ๐˜ฆ๐˜ฏ๐˜ด๐˜ถ๐˜ณ๐˜ฆ๐˜ด ๐˜ต๐˜ฉ๐˜ข๐˜ต ๐˜ฅ๐˜ฐ๐˜ธ๐˜ฏ๐˜ด๐˜ต๐˜ณ๐˜ฆ๐˜ข๐˜ฎ ๐˜ง๐˜ญ๐˜ฐ๐˜ธ ๐˜ฅ๐˜ฐ๐˜ฆ๐˜ด ๐˜ฏ๐˜ฐ๐˜ต ๐˜ณ๐˜ฆ๐˜ด๐˜ถ๐˜ฎ๐˜ฆ ๐˜ฐ๐˜ฏ ๐˜ค๐˜ข๐˜ฏ๐˜ค๐˜ฆ๐˜ญ๐˜ญ๐˜ข๐˜ต๐˜ช๐˜ฐ๐˜ฏ ๐˜ฆ๐˜ท๐˜ฆ๐˜ฏ ๐˜ช๐˜ง ๐˜ต๐˜ฉ๐˜ฆ ๐˜ฆ๐˜ญ๐˜ฆ๐˜ฎ๐˜ฆ๐˜ฏ๐˜ต๐˜ธ๐˜ข๐˜ด ๐˜ข๐˜ญ๐˜ณ๐˜ฆ๐˜ข๐˜ฅ๐˜บ ๐˜ฆ๐˜ฎ๐˜ช๐˜ต๐˜ต๐˜ฆ๐˜ฅ ๐˜ฃ๐˜บ ๐˜ต๐˜ฉ๐˜ฆ ๐˜ถ๐˜ฑ๐˜ด๐˜ต๐˜ณ๐˜ฆ๐˜ข๐˜ฎ ๐˜ง๐˜ญ๐˜ฐ๐˜ธ.


You will see a reference to an "upstream" and a "downstream" flow everywhere in the docs.


It was challenging for me to understand what those definitions mean, so I put together an animation to help you understand as well.


โฌ†๏ธ Upstream flow - When you apply an intermediate operator to a flow, you are affecting the part of the flow that comes before (or "upstream of") the operator.


โฌ‡๏ธ Downstream flow - Side of the flow that proceeds after applying an intermediate operator.


Hope my animation helps you clear up the confusion!

ย 
ย 
ย 

Recent Posts

See All

Comentarios

Obtuvo 0 de 5 estrellas.
Aรบn no hay calificaciones

Agrega una calificaciรณn

©2025 by Mykola Miroshnychenko

bottom of page