Reduce Number of Reconnection Callbacks on Chat app
See original GitHub issueProblem
The reconnection callbacks fire frequently as a means of catching up the user when:
- They move from offline to online
- They move from active to inactive
- Laptop is closed and reopened
- This is a problem because the act of firing all the reconnection callbacks is a very expensive task. There isn’t really any great reason why it should be so expensive and the reasons why should be investigated and fixed. However, this issue is only about reducing how often they run.
To do this we need to stop using the AppState listener
and instead use Pusher’s pusher:subscription_succeeded
event as mentioned here.
The AppState listener here was added so that we would be able to catch up on missed data when putting the iOS or Android app into the background. Pusher loses connectivity in this case and when it comes back online we aren’t sure if we’ve missed anything so we naively assume that we have and fire the reconnection callbacks.
See relevant code section here
Why is this important?
We should only ask users to “catch up” on data they’ve missed when they need to.
Solution
Reduce number of calls to reconnection callbacks by ditching AppState listener in favor of the Pusher solution linked in the article
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (14 by maintainers)
Top GitHub Comments
Yep, you got it.
Oh. I see. So you mean we only call the reconnection on one channel for comments on the report and we don’t need to call reconnectionCallbacks for other channels. Nice. 💯
So Now reconnectionCallacks will fire when
I will prepare a PR and test it thoroughly.