ngxingyu
Committed by GitHub

Update dependency_management.md

@@ -34,7 +34,7 @@ The methods and it's configurable parameters are: @@ -34,7 +34,7 @@ The methods and it's configurable parameters are:
34 34
35 ### Get.put() 35 ### Get.put()
36 36
37 -The most common way of insert a dependency. Good for the controllers of your views for example. 37 +The most common way of inserting a dependency. Good for the controllers of your views for example.
38 38
39 ```dart 39 ```dart
40 Get.put<SomeClass>(SomeClass()); 40 Get.put<SomeClass>(SomeClass());
@@ -195,7 +195,7 @@ int count = Get.find<SharedPreferences>().getInt('counter'); @@ -195,7 +195,7 @@ int count = Get.find<SharedPreferences>().getInt('counter');
195 print(count); // out: 12345 195 print(count); // out: 12345
196 ``` 196 ```
197 197
198 -To remove a instance of Get: 198 +To remove an instance of Get:
199 199
200 ```dart 200 ```dart
201 Get.delete<Controller>(); //usually you don't need to do this because GetX already delete unused controllers 201 Get.delete<Controller>(); //usually you don't need to do this because GetX already delete unused controllers
@@ -207,8 +207,8 @@ First, let's of the `fenix` of Get.lazyPut and the `permanent` of the other meth @@ -207,8 +207,8 @@ First, let's of the `fenix` of Get.lazyPut and the `permanent` of the other meth
207 207
208 The fundamental difference between `permanent` and `fenix` is how you want to store your instances. 208 The fundamental difference between `permanent` and `fenix` is how you want to store your instances.
209 209
210 -Reinforcing: by default, GetX deletes instances when they are not is use.  
211 -It means that: If screen 1 has controller 1 and screen 2 has controller 2 and you remove the first route from stack, (like if you use `Get.off()` or `Get.offNamed()`) the controller 1 lost it's use so it will be erased. 210 +Reinforcing: by default, GetX deletes instances when they are not in use.
  211 +It means that: If screen 1 has controller 1 and screen 2 has controller 2 and you remove the first route from stack, (like if you use `Get.off()` or `Get.offNamed()`) the controller 1 lost its use so it will be erased.
212 212
213 But if you want to opt for using `permanent:true`, then the controller will not be lost in this transition - which is very useful for services that you want to keep alive throughout the entire application. 213 But if you want to opt for using `permanent:true`, then the controller will not be lost in this transition - which is very useful for services that you want to keep alive throughout the entire application.
214 214
@@ -216,9 +216,9 @@ But if you want to opt for using `permanent:true`, then the controller will not @@ -216,9 +216,9 @@ But if you want to opt for using `permanent:true`, then the controller will not
216 216
217 Proceeding with the differences between methods: 217 Proceeding with the differences between methods:
218 218
219 -- Get.put and Get.putAsync follow the same creation order, with the difference that the second uses an asynchronous method: those two methods create and initialize the instance. That one is inserted directly in the memory, using the internal method `insert` with the parameters `permanent: false` and `isSingleton: true` (this isSingleton parameter only porpuse is to tell if it is to use the dependency on `dependency` or if it is to use the dependency on `FcBuilderFunc`). After that, `Get.find()` is called that immediately initialize the instances that are on memory. 219 +- Get.put and Get.putAsync follows the same creation order, with the difference that the second uses an asynchronous method: those two methods creates and initializes the instance. That one is inserted directly in the memory, using the internal method `insert` with the parameters `permanent: false` and `isSingleton: true` (this isSingleton parameter only porpuse is to tell if it is to use the dependency on `dependency` or if it is to use the dependency on `FcBuilderFunc`). After that, `Get.find()` is called that immediately initialize the instances that are on memory.
220 220
221 -- Get.create: As the name implies, it will "create" your dependency! Similar to `Get.put()`, it also call the internal method `insert` to instancing. But `permanent` became true and `isSingleton` became false (since we are "creating" our dependency, there is no way for it to be a singleton instace, that's why is false). And because it has `permanent: true`, we have by default the benefit of not losing it between screens! Also, `Get.find()` is not called immediately, it wait to be used in the screen to be called. It is created this way to make use of the parameter `permanent`, since then, worth noticing, `Get.create()` was made with the goal of create not shared instances, but don't get disposed, like for example a button in a listView, that you want a unique instance for that list - because of that, Get.create must be used together with GetWidget. 221 +- Get.create: As the name implies, it will "create" your dependency! Similar to `Get.put()`, it also calls the internal method `insert` to instancing. But `permanent` became true and `isSingleton` became false (since we are "creating" our dependency, there is no way for it to be a singleton instace, that's why is false). And because it has `permanent: true`, we have by default the benefit of not losing it between screens! Also, `Get.find()` is not called immediately, it wait to be used in the screen to be called. It is created this way to make use of the parameter `permanent`, since then, worth noticing, `Get.create()` was made with the goal of create not shared instances, but don't get disposed, like for example a button in a listView, that you want a unique instance for that list - because of that, Get.create must be used together with GetWidget.
222 222
223 - Get.lazyPut: As the name implies, it is a lazy proccess. The instance is create, but it is not called to be used immediately, it remains waiting to be called. Contrary to the other methods, `insert` is not called here. Instead, the instance is inserted in another part of the memory, a part responsable to tell if the instance can be recreated or not, let's call it "factory". If we want to create something to be used later, it will not be mix with things been used right now. And here is where `fenix` magic enters: if you opt to leaving `fenix: false`, and your `smartManagement` are not `keepFactory`, then when using `Get.find` the instance will change the place in the memory from the "factory" to common instance memory area. Right after that, by default it is removed from the "factory". Now, if you opt for `fenix: true`, the instance continues to exist in this dedicated part, even going to the common area, to be called again in the future. 223 - Get.lazyPut: As the name implies, it is a lazy proccess. The instance is create, but it is not called to be used immediately, it remains waiting to be called. Contrary to the other methods, `insert` is not called here. Instead, the instance is inserted in another part of the memory, a part responsable to tell if the instance can be recreated or not, let's call it "factory". If we want to create something to be used later, it will not be mix with things been used right now. And here is where `fenix` magic enters: if you opt to leaving `fenix: false`, and your `smartManagement` are not `keepFactory`, then when using `Get.find` the instance will change the place in the memory from the "factory" to common instance memory area. Right after that, by default it is removed from the "factory". Now, if you opt for `fenix: true`, the instance continues to exist in this dedicated part, even going to the common area, to be called again in the future.
224 224