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
perf: Example of not duplicating data with repository pattern in todos example #4167
Comments
In this bloc the same model is used in both places but in more real-world, larger apps the data exposed by the repository would likely be quite different from the data exposed by a bloc and the bloc would handle transforming the repository data into the required state. You can see the
There is still a single source of truth (in this case the repository) and one or more blocs may access data exposed by the repository and transform it as needed into state consumed by the presentation. Hope that helps 👍 |
Thanks for the response @felangel I understood your point but in that case if I want to utilise the hydrated bloc to keep my data hydrated I would have to lose that functionality and implement a persistent storage on the repository level. |
Hydrated Bloc is meant to cache your application state. If you want to cache repository data then I recommend adding a dedicated cache using your storage solution of choice ( |
Closing this for now since there doesn't appear to be any actionable next steps. Feel free to leave any follow ups and I'm happy to continue the discussion 👍 |
Description
In the TodosOverviewBloc
We are storing the data in the state in the above manner but we are storing the same data at the repository level in local_storage_todos_api
late final _todoStreamController = BehaviorSubject<List<Todo>>.seeded(const []);
To enhance this setup and promote a more realistic approach for real-world applications, consolidating data storage into a single location would be highly beneficial. This improvement could streamline processes for developers facing similar scenarios, offering clearer management and maintenance of data.
The text was updated successfully, but these errors were encountered: