ildar.i [Android]
04/12/2022, 12:08 PMildar.i [Android]
04/12/2022, 12:09 PMchristophsturm
04/12/2022, 12:10 PMildar.i [Android]
04/12/2022, 12:11 PMJoffrey
04/12/2022, 12:18 PMwithContext when needed would just be clearer than using callback-based methods (the whole point of coroutines is the direct style, and you're creating a callback-based wrapper on top, which is kinda the opposite of the intent). Why not define your methods as suspend functions instead of launching coroutines in a custom scope?ildar.i [Android]
04/12/2022, 12:29 PMJoffrey
04/12/2022, 12:31 PMlifecycleScope or viewModelScope (depending on the place) without creating your own. This allows coroutines to be cancelled at the proper time in case they are not needed anymoreJoffrey
04/12/2022, 12:35 PMCancellationException. In this particular case I don't see a way this could cause any harm, but in general it's a bad idea to not re-throw it because it could mess up with cancellation of your coroutines.
Catching Throwable is rather bad practice too, because it caches things like OutOfMemoryError, NoClassDefFoundError and other unrecoverable stuff like this, which you probably shouldn't try to catch.
If what you want is to ensure the loader stops, you can use a finally block instead.ildar.i [Android]
04/12/2022, 12:43 PMstop. Custom scope so we can avoid implementation details at the call site and to have one line of code there instead of three. Thank you very much for your feedback 🙏Joffrey
04/12/2022, 12:45 PMJoffrey
04/12/2022, 12:47 PMplus we should call HIDE_LOADING regardlessThat's the role of
finally blocks, you should probably use it to express this intentJoffrey
04/12/2022, 12:48 PMCustom scope so we can avoid implementation details at the call siteScopes are not implementation details, they are very high-level because they decide for how long the caller is interested in the result - you technically don't know it in your abstract implementation
Joffrey
04/12/2022, 12:49 PMildar.i [Android]
04/12/2022, 1:03 PMhenrikhorbovyi
04/13/2022, 12:44 AMildar.i [Android]
04/13/2022, 7:31 AMhenrikhorbovyi
04/14/2022, 12:24 AM