-
In our app (Android), we have a custom coroutine scope that is active, while the user is logged in and canceled once they log out. It would be nice to be able to scope the fetcher calls to this scope, so the running call kept even if there are no subscribers, but only cancel on logout. Imagine starting the call on one screen, then moving away to a screen that does not subscribe to the store and returning back - it would be great to just receive result of the first call instead of restarting the call again. I found out that Furthermore, also when building from source and setting Did I miss something and is there a way to achieve the above? If there is not, shouldn't there be? Thanks PS. I am experimenting with GitHub discussions because I am not sure this warrants opening an issue, but I can open one if you think it would better fit there. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The keep alive is for sharing purposes when there is no source of truth so it won't help here. Also, from Store's perspective, keeping those calls alive looks very wrong (keep in mind, they could also be streams and you wouldn't want Store to keep every stream alive). I think it is better for you to solve this outside Store. For such calls where you want it to stay alive, you can move the store request to the |
Beta Was this translation helpful? Give feedback.
The keep alive is for sharing purposes when there is no source of truth so it won't help here.
Also, from Store's perspective, keeping those calls alive looks very wrong (keep in mind, they could also be streams and you wouldn't want Store to keep every stream alive).
I think it is better for you to solve this outside Store. For such calls where you want it to stay alive, you can move the store request to the
userScope
and pass it back to the caller scope using an explicit channel. A bit verbose but given that it is intentionally denying structured concurrency, it might even be the right thing to keep verbose. (you can also always consider writing a wrapper for it :) )