Avoid ANRs when collecting flows in Presenters #577
-
Hi, I just ran into the issue that the Presenter was collecting flows from a repository on the default (main) dispatcher -> producing ANRs. so we just have to be careful when using i wonder if someone has any lint rules or sth in place to not fall into the trap. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It sounds like your Flow should have used |
Beta Was this translation helpful? Give feedback.
It sounds like your Flow should have used
flowOn(IO)
before it ever got near your UI. Just like how suspending functions should be "main" safe, Flows should be the same. It's perfectly acceptable to encapsulate blocking work within one, but that Flow should force itself to an appropriate dispatcher before it leaks out to somewhere where that context can be lost.