-
Notifications
You must be signed in to change notification settings - Fork 503
update how async permissions are handled #147
base: master
Are you sure you want to change the base?
Conversation
This looks great, I like getting rid of the |
We're still using the waitingFor but not on the main thread anymore. I think we'll only be able to remove them if we move to a completion/promise model for these async permissions. The |
Ah, interesting. Thanks! Do you have a particular repro step for blocking the main thread so I can reproduce the issue and confirm the fix? I imagine it occurs with the bluetooth permission which I don't use pscope for frequently... |
I spent a while wondering why the popup was never showing up in the example but the background modes were disabled :/ Anyways, I tried to reproduce the error in the example but I wasn't able. I think in my app, since I call bluetooth methods on startup, and also show the permissions scope alert on startup, it could happen that show was called before BLE had updated. Actually I found a way to simulate the issue. Wrap the contents of the With these changes the alert will show up after ~5s of startup. |
@nickoneill I've recently updated this further because I had found another condition in which it would get stuck waiting for bluetooth to update. With these changes all the waiting operations are guaranteed to be off the main thread. |
Background mode shouldn't be enabled in the library. Add a note in the README, under extra-requirements-for-permissions |
@bre7 It's not for the library but only for the examples, it was already enabled for the swift example I enabled it for the |
✋ my bad |
Thanks for the additional changes @felix-dumit, I'll review next time we set up a release. |
f99202a
to
e1037a0
Compare
e1037a0
to
9518348
Compare
Changed how async permissions are handled, as I was getting the main thread stuck waiting for an update sometimes.
Now the
getResultsForConfig
will wait for updates in the background before executing completion in main thread.