-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StreamChat dispose() tears down the Client connection #4
Labels
bug
Something isn't working
Comments
Hi @isaiahtaylor |
imtoori
added a commit
that referenced
this issue
Mar 13, 2020
6 tasks
5 tasks
2 tasks
6 tasks
6 tasks
1 task
1 task
1 task
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, my team is evaluating Stream and I am very happy with the Flutter and React UI Kits so far. The flutter kit particularly was the big differentiator for us. Kudos!
One problem I was having was that tabbing away from the chat window using
BottomNavigationBar
tabs caused the Client object to get torn down and the connection to get disconnected, so that when I navigate back to it again I get errors that it has been disconnected.This is despite the fact that my Client is initialized before
runApp
.Root Cause
I found that
StreamChat.dispose()
callswidget.client.dispose()
. This effectively ties the lifecycle of the Client object to the lifecycle of a widget that uses it. From a memory perspective this is not saving anything; in the Stream documentation it is recommended that theClient
be created at the top and persist through the lifecycle of the entire app, so it doesn't make sense to dispose of that top level Client object when disposing of a widget that makes use of it.Workaround
If anyone is experiencing a similar issue, I worked around it by extending the
Client
class and overriding thedispose
method to do nothing:Then, simply use this class rather than
Client
at the top of your app:After this, the StreamChat widget will get torn down and restored as you tab back and forth, but the
Client
will survive it.The text was updated successfully, but these errors were encountered: