Skip to content
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

Caching the Model Data #17

Open
Amerr opened this issue Apr 10, 2020 · 1 comment
Open

Caching the Model Data #17

Amerr opened this issue Apr 10, 2020 · 1 comment

Comments

@Amerr
Copy link

Amerr commented Apr 10, 2020

First of all thanks for provider_architecture in reducing the pain of building up a large and maintainable app

After reading couple of issues and blog posts. Registering viewModel as registerLazySingleton rather than registerFactory to avoid multiple requests in API or any data layer.
I want to know how to achieve caching in this architecture?

  • One way I could think of handling in Services which would give cached data and making background call to update the new data.

But I am interested in your view and how do you approach it. It would be nice if you are able to explain it with a real use case.

@FilledStacks
Copy link
Owner

Hi @Amerr I handle all my caching in the services. The viewmodel would only make multiple requests if you're requesting data in the constructor. Which you probably shouldn't. My services handle anything like that. OrderService makes a request, keeps the orders locally or in a db, when requesting it again I first serve from the DB and then go to the API and fetch that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants