brianegan / brianegan/flutter_architecture_samples

How to use 'web_socket_channel' in todos_repository_simple

Open
#159 1 comment 0 reactions 0 assignees View on GitHub
good first issue
Dominant language
Dart
Stars
8.9k
Forks
1.7k
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](https://www.didierboelens.com/2018/06/web-sockets---build-a-real-time-game/) : reload the UI directly in widget by mapping switch case.
[Flutter_bloc](https://github.com/felangel/bloc/tree/master/examples/flutter_todos): need to reload the UI through bloc_state.

Thanks.

Contributor guide

Open the contributing guide

Research direction

No file or test is named. Start by reviewing the todos_repository_simple example and its current REST provider structure, then compare it with the requested web_socket_channel and fileStorage approach. Done means documenting how socket updates flow through the repository and flutter_bloc state so the UI can react to server messages.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
documentation, mobile
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.