Skip to content
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

How to use 'web_socket_channel' in todos_repository_simple #159

Open
jangya opened this issue Nov 14, 2019 · 1 comment
Open

How to use 'web_socket_channel' in todos_repository_simple #159

jangya opened this issue Nov 14, 2019 · 1 comment

Comments

@jangya
Copy link

jangya commented Nov 14, 2019

Web socket as data Provider


todos_repository_simple explains nicely about the benefits of using repository as singleton. But no where it's mentioned how to handle the web sockets.

How can I use web socket (webSocket and fileStorage) instead of rest (webClient and fileStorage) ?

Some key points between web socket and rest.

  • The name itself signify socket is stateLess and rest is stateFull
  • socket is bidirectional : Server can send data to client and client will have a callback to perform accordingly and vice versa.

My dataProvider is socket and fileStorage and follows flutter_bloc architecture.

Every time we receive data from socket :
Article : reload the UI directly in widget by mapping switch case.
Flutter_bloc: need to reload the UI through bloc_state.

Thanks.

@mmcc007
Copy link
Collaborator

mmcc007 commented Nov 14, 2019

Here is an example of using Aqueduct server and a dart client to implement a chat room using sockets:
https://github.com/stablekernel/aqueduct_examples/tree/master/cli_chat_websockets
Can probably adapt this to the todos_repository_simple or your app.
Plus you have dart on both the client and server sides and aqueduct is easy enough to deploy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants