I stumbled upon <https://blog.p-y.wtf/whilesubscri...
# android
c
I stumbled upon https://blog.p-y.wtf/whilesubscribed5000 after watching this video where I was also a bit confused by the 5000 magic number. I was also actually got off-guard that apparently you can use Lazily instead of whileSubcribed(5000) if you use androidx.navigation. What do you all use? 1️⃣ whileSubscribed(5000) 2️⃣ PY's solution of a custom
SharingStarted.WhileSubscribedOrRetained
3️⃣ Use navigation with
Lazily
1️⃣ 5
2️⃣ 2
3️⃣ 1
i
1 is the only right choice.
Lazily
is absolutely, positively the wrong choice (and will keep work going while that screen is on the back stack)
🤯 2
👆🏼 1
1
c
So not even the custom solution? So much learned today! 😄
also makes sense why i couldn't find the
Lazily
solution in the navigation docs
i
It is too clever by about 5x and definitely not tested across every API level and OEM customization 🙃
today i learned 1
a
I would say
Lazily
is applicable if you using a shared-view-model use-case where you have a flow and you have to keep the stream alive for each fragment/composable that is collecting from that flow, even when that is on back stack. Correct me if I am wrong @Ian Lake
h
I like to think of 5000 not as a magic number but as a time out and that’s what it is
r
As I understand, 5000 is a magic number to account for the time most configuration changes need on most devices, i.e. a sluggish old device being rotated, or a very fast navigation to a child route and then back.
c
I thought 5_000 because that's the ANR threshold
🤔 1