-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix permission request subjects being not complete #319
base: master
Are you sure you want to change the base?
Fix permission request subjects being not complete #319
Conversation
Hello! Sorry but I just can't get it. I mean why it should throw? |
When application goes to background android permission dialog disappears and if you are not specifically disposing request, it cant be started, so if it cant be started after some action, library should handle it. Only way to end this dispose was to throw error to subject. |
The library should cancel all requests the user is not able to complete. Otherwise, there could unexpected memory leaks if the user of the library is not aware of such situations. This is especially true if you are subscribing to RxPermissions inside ViewModel, which does not have such states at all. |
I have never seen and never get into such scenario. How could I reproduce this case? |
|
Throwable is used pretty often as a canceling event. For example Object.await() uses exception to interrupt waiting for the state. Or job cancelation at kotlinx.coroutines. But yeah, non-throwable could be feasible solution as well.
For example use permissions is services which could live longer than single fragment:
I suppose the original ViewModel idea states the same. However, in reality, it is very hard to maintain code with many bidirectional communication points between fragment and ViewModel. And believe me, in a large codebase it became unmanageable spaghetti pretty fast. |
You can reproduce the issue in such scenario:
And then: button click -> permissions dialog appears -> don't do any clicks on dialog and put app to the background via "Home" button click -> click on application icon -> app resumes -> click on UI button again -> permission dialog won't appear anymore and user can't perform intended action. There is already similar issues created about this behaviour, for example: vanniktech/RxPermission#66 (it is of course different library but behaviour is the same in this library). |
okey |
1 similar comment
okey |
Fix issue, when permission request is started, but then app put to background and resumed
So now all requests could be finished with cancelation exception and requests cleared from list