Comments (4)
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 👍
from bloc.
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 StatsBloc
for example also subscribes to the todos exposed by the repository and it converts that data into statistics that are later presented in the UI.
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.
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 👍
from bloc.
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
StatsBloc
for example also subscribes to the todos exposed by the repository and it converts that data into statistics that are later presented in the UI.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.
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.
Is there a way to handle that case?
from bloc.
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
StatsBloc
for example also subscribes to the todos exposed by the repository and it converts that data into statistics that are later presented in the UI.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.
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. Is there a way to handle that case?
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 (hive
, sqflite
, etc.)
from bloc.
Related Issues (20)
- fix: emitting a state in a closed Cubit throws an error HOT 5
- Unable to upgrade to 4.0.0 Bloc plugin on Intellij HOT 5
- question: I need to access the latest state of bloc outside of a widget tree in a helper function. HOT 5
- Emit that occurs during init doesn't cause a rebuild HOT 1
- How to rely on data from another Stream? HOT 4
- question: is this considered a anti pattern if a repository depends on another bloc. HOT 2
- docs: RTL in documentation
- feat: allow user to choose which event or state change to be captured in the changeStack or not HOT 2
- feat: Translation of menu and prev, next, note title in the document HOT 1
- question: UI interactivity and separation of concerns HOT 2
- question: Having a bloc inherit from a another bloc HOT 1
- style: Move the "props" getter to the parent (sealed) class HOT 1
- fix: How to listen to multiple streams in a single event? HOT 1
- feat: can we rename copyWith to replaceWith HOT 1
- fix: com.bloc.intellij_generator_plugin.action.GenerateBlocAction retains disposed Project HOT 3
- feat: Enhance BlocBuilder with Dependencies for Selective State Changes HOT 1
- [help] Best Practice for Sharing Events and States Across Multiple Blocs, Bloc to Bloc communications HOT 8
- fix: BlocBuilder doesn't receive state when emitted from async loop HOT 4
- How to inspect bloc in Flutter Inspector? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bloc.