Comments (3)
Hello @nxcco !
The difference between providers and services are basically:
-
Providers are the source of your data, be it an API or a DB for example, then it provides the necessary information for your application.
-
Services are application services, more specifically our GetXServices, which are services / features that will be arranged by more than one part of the application, different from our controllers which, in this context, are available for each module.
I have two good examples of services for you. -
What I use most in this approach is an auth_service for example, note that each service may or may not have a repository, it depends on whether or not it has integration with providers, in the case of auth, it probably will, and in this service I concentrate everything related to authentication, such as registration, login, logout, I can use it and its respective functions of different controllers. Example, controller login will consume this service to log in, in the profile there is a button to log out and you will call this same service only with Get.find, another good use is to keep something in it, in case I keep a user or a token for example, right in all the controllers that you need this object it will already be available, without any getUser or something, soon it would take the weight of a call getUser from the controller of the profile module for example, besides you want to access his id in several other cases, for example, and your service will be available there.
-
Another good example that I used in the examples in this doc is the app_config_service.
Imagine that, just like in the example, you decide to change the theme of the app, and save it, and retrieve from GetStorage which is the last option marked to remember when reopening the app.
Soon you can do this from one or more places, at the same time wanting to recover this state to leave a white or black button, for example and this service will be available, just use Get.find.
End that is why our services are at this level of the application, in date, as it serves all modules.
See this example. -
As mentioned, controllers are responsible for controlling the module in which it is assigned, and services are not necessarily exclusive, you can call them on any controller, as long as the service is alive in memory, so it is a level above our modules , and the controllers are internal to each module, in other words, each module is the responsibility of a controller, and it is removed from memory at the right time, Services are not exclusive, you can mix in more than one module, and stay alive in memory until the app closes or you give auth_service.delete()
I will leave the issue open for today, in case there are any more questions.
from getx_pattern.
Whenever you need us, we'll be here, see you later. xD
from getx_pattern.
Thank you for taking the time to clear things up!😄
from getx_pattern.
Related Issues (20)
- For larger project HOT 1
- Confused about the folder structure. HOT 1
- A working minimal example would be greatly appreciated HOT 7
- Where do the dialogs go? HOT 2
- Do we really need the repository? HOT 2
- Dúvida no conceito de módulo HOT 5
- Duplication of initial page HOT 1
- Dúvida: onde ficariam as interfaces que são implementadas pelos `services`, `repositories` e `providers`? HOT 4
- Why is there only Android configuration under UI, IOS configuration? I don't think it makes a lot of sense HOT 1
- why folder views is double? HOT 2
- Shared controller is multiple views HOT 1
- why you dont getConnect as provider? HOT 4
- Modules... HOT 1
- Where would I put the StreamSubscription? HOT 2
- folder name: exEmples and exAmples HOT 1
- Example code HOT 1
- Site Translations HOT 4
- examples _and_ exemples? HOT 2
- Understanding the difference between Services and Providers, along with their interaction with Repositories 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 getx_pattern.