Coder Social home page Coder Social logo

Comments (4)

felangel avatar felangel commented on July 18, 2024 1

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.

felangel avatar felangel commented on July 18, 2024

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.

faisalansari0367 avatar faisalansari0367 commented on July 18, 2024

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.

felangel avatar felangel commented on July 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.