Nipodemos

translating recent ptbr changes in docs to english

@@ -66,11 +66,11 @@ To remove a instance of Get: @@ -66,11 +66,11 @@ To remove a instance of Get:
66 Get.delete<Controller>(); 66 Get.delete<Controller>();
67 ``` 67 ```
68 68
69 -## Options 69 +## Instancing methods
70 70
71 -When you use Get.put, lazyPut and putAsync you will have some options that you can change if you want 71 +Although Getx already delivers very good settings for use, it is possible to refine them even more so that it become more useful to the programmer. The methods and it's configurable parameters are:
72 72
73 -- On Get.put(): 73 +- Get.put():
74 74
75 ```dart 75 ```dart
76 Get.put<S>( 76 Get.put<S>(
@@ -100,7 +100,7 @@ Get.put<S>( @@ -100,7 +100,7 @@ Get.put<S>(
100 ) 100 )
101 ``` 101 ```
102 102
103 -- On Get.lazyPut: 103 +- Get.lazyPut:
104 104
105 ```dart 105 ```dart
106 Get.lazyPut<S>( 106 Get.lazyPut<S>(
@@ -121,7 +121,7 @@ Get.lazyPut<S>( @@ -121,7 +121,7 @@ Get.lazyPut<S>(
121 ) 121 )
122 ``` 122 ```
123 123
124 -- On Get.putAsync: 124 +- Get.putAsync:
125 125
126 ```dart 126 ```dart
127 Get.putAsync<S>( 127 Get.putAsync<S>(
@@ -139,6 +139,45 @@ Get.putAsync<S>( @@ -139,6 +139,45 @@ Get.putAsync<S>(
139 bool permanent = false 139 bool permanent = false
140 ``` 140 ```
141 141
  142 +- Get.create:
  143 +
  144 +```dart
  145 +Get.create<S>(
  146 + // required: a function that returns a class that will be "fabricated" every
  147 + // time `Get.find()` is called
  148 + // Example: Get.create<YourClass>(() => YourClass())
  149 + FcBuilderFunc<S> builder,
  150 +
  151 + // optional: just like Get.put(), but it is used when you need multiple instances
  152 + // of a of a same class
  153 + // Useful in case you have a list that each item need it's own controller
  154 + // needs to be a unique string. Just change from tag to name
  155 + String name,
  156 +
  157 + // optional: just like int`Get.put()`, it is for when you need to keep the
  158 + // instance alive thoughout the entire app. The difference is in Get.create
  159 + // permanent is true by default
  160 + bool permanent = true
  161 +```
  162 +
  163 +### Diferences between methods:
  164 +
  165 +We will talk about the variables `_factory` and `_singl`. Both are essential in the process of creating
  166 + and using our dependencies, because is by it that we can store, dele and recreate the instances.
  167 +
  168 +First, let's of the `fenix` of Get.lazyPut and the `permanent` of the other methods.
  169 +
  170 +The fundamental difference between `permanent` and `fenix` is how you want to store your instances.
  171 +Reinforcing: by default, GetX deletes instances when they are not is use (let's say screen 1 has controller 1 and screen 2 has controller 2. When you move from screen 1 to screen 2, the controller 1 lost its use so it is erased), but if you want to opt to `permanent:true`, then the controller will not be lost in this transition - which is very usefult for services that you want to keep alive thoughout the entire application. `fenix` in the other hand is for services that you don't worry in losing between screen changes, but when you need that service, you expect that it is alive. So basically, it will dispose the unused controller/service/class, but when you need that, it will "recreate from the ashes" a new instance.
  172 +
  173 +Proceeding with the differences between methods:
  174 +
  175 +- Get.put and Get.putAsync follow the same creation order, with the difference that asyn opt for applying a 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.
  176 +
  177 +- 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.
  178 +
  179 +- 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.
  180 +
142 ## Bindings 181 ## Bindings
143 182
144 One of the great differentials of this package, perhaps, is the possibility of full integration of the routes, state manager and dependency manager. 183 One of the great differentials of this package, perhaps, is the possibility of full integration of the routes, state manager and dependency manager.