brianegan/flutter_architecture_samples

How to use 'web_socket_channel' in todos_repository_simple

Open

#159 opened on Nov 14, 2019

View on GitHub
 (1 comment) (0 reactions) (0 assignees)Dart (1,717 forks)batch import
good first issue

Repository metrics

Stars
 (8,920 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

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.

Contributor guide