Closed synw closed 4 years ago
@synw hello!
My question about API like this is how to handle reconnect and resubscription events. For example as soon as await chan.subscribe(...)
finished it's work we don't have a callback that will be called after reconnect. The same for connect/disconnect during connection lifetime. Or am I missing sth?
Good point. I'll work on adding an autoreconnect/resubscribe mechanism to this experimental api. And better error management. I need to dig more in this library's code and use it in a few apps to get a better understanding and eventually produce something realistic
Hi. Trying to learn this library I ended up making a helper class that reduces the api surface and the boilerplate. Commented code and an example are available: https://github.com/synw/centrifuge-dart/tree/connection_manager/example/manager
It looks like this:
This approach is based on callbacks and completers: this way the user does not have to manage half a dozen stream subscriptions. I added a
CentrifugoChannel
model as a paradigm for the library user