Nipodemos

edits done in english documentation

@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 - [Get.lazyPut](#getlazyput) 6 - [Get.lazyPut](#getlazyput)
7 - [Get.putAsync](#getputasync) 7 - [Get.putAsync](#getputasync)
8 - [Get.create](#getcreate) 8 - [Get.create](#getcreate)
9 - - [Diferences between methods:](#diferences-between-methods) 9 + - [Differences between methods:](#differences-between-methods)
10 - [Bindings](#bindings) 10 - [Bindings](#bindings)
11 - [How to use](#how-to-use) 11 - [How to use](#how-to-use)
12 - [BindingsBuilder](#bindingsbuilder) 12 - [BindingsBuilder](#bindingsbuilder)
@@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
14 - [SmartManagement.full](#smartmanagementfull) 14 - [SmartManagement.full](#smartmanagementfull)
15 - [SmartManagement.onlyBuilders](#smartmanagementonlybuilders) 15 - [SmartManagement.onlyBuilders](#smartmanagementonlybuilders)
16 - [SmartManagement.keepFactory](#smartmanagementkeepfactory) 16 - [SmartManagement.keepFactory](#smartmanagementkeepfactory)
  17 + - [How bindings work under the hood](#how-bindings-work-under-the-hood)
17 - [Notes](#notes) 18 - [Notes](#notes)
18 19
19 Get has a simple and powerful dependency manager that allows you to retrieve the same class as your Bloc or Controller with just 1 lines of code, no Provider context, no inheritedWidget: 20 Get has a simple and powerful dependency manager that allows you to retrieve the same class as your Bloc or Controller with just 1 lines of code, no Provider context, no inheritedWidget:
@@ -32,7 +33,7 @@ So you can use your controller (or Bloc class) normally @@ -32,7 +33,7 @@ So you can use your controller (or Bloc class) normally
32 Imagine that you have navigated through numerous routes, and you need a data that was left behind in your controller, you would need a state manager combined with the Provider or Get_it, correct? Not with Get. You just need to ask Get to "find" for your controller, you don't need any additional dependencies: 33 Imagine that you have navigated through numerous routes, and you need a data that was left behind in your controller, you would need a state manager combined with the Provider or Get_it, correct? Not with Get. You just need to ask Get to "find" for your controller, you don't need any additional dependencies:
33 34
34 ```dart 35 ```dart
35 -Controller controller = Get.find(); 36 +Controller controller = Get.find(); // or final controller = Get.find<Controlelr>();
36 //Yes, it looks like Magic, Get will find your controller, and will deliver it to you. You can have 1 million controllers instantiated, Get will always give you the right controller. 37 //Yes, it looks like Magic, Get will find your controller, and will deliver it to you. You can have 1 million controllers instantiated, Get will always give you the right controller.
37 ``` 38 ```
38 39
@@ -81,6 +82,8 @@ Although Getx already delivers very good settings for use, it is possible to ref @@ -81,6 +82,8 @@ Although Getx already delivers very good settings for use, it is possible to ref
81 82
82 ### Get.put() 83 ### Get.put()
83 84
  85 +The most common way of inserting a dependency. Good for the controllers of your views for example.
  86 +
84 ```dart 87 ```dart
85 Get.put<S>( 88 Get.put<S>(
86 // mandatory: the class that you want to get to save, like a controller or anything 89 // mandatory: the class that you want to get to save, like a controller or anything
@@ -116,10 +119,11 @@ Get.put<LoginController>(LoginController(), permanent: true) @@ -116,10 +119,11 @@ Get.put<LoginController>(LoginController(), permanent: true)
116 119
117 ### Get.lazyPut 120 ### Get.lazyPut
118 121
  122 +With lazyPut, the dependency will be only instantiated when it's called. This is particularly useful if you want to instantiate several classes in just one place, but don't need that instances immediatly
  123 +
119 ```dart 124 ```dart
120 Get.lazyPut<S>( 125 Get.lazyPut<S>(
121 // mandatory: a method that will be executed when your class is called for the first time 126 // mandatory: a method that will be executed when your class is called for the first time
122 - // Example: Get.lazyPut<Controller>( () => Controller() )  
123 InstanceBuilderCallback builder, 127 InstanceBuilderCallback builder,
124 128
125 // optional: same as Get.put(), it is used for when you want multiple different instance of a same class 129 // optional: same as Get.put(), it is used for when you want multiple different instance of a same class
@@ -143,15 +147,19 @@ Get.lazyPut<FirebaseAuth>( @@ -143,15 +147,19 @@ Get.lazyPut<FirebaseAuth>(
143 tag: Math.random().toString(), 147 tag: Math.random().toString(),
144 fenix: true 148 fenix: true
145 ) 149 )
  150 +
  151 +// example 2:
  152 +Get.lazyPut<Controller>( () => Controller() )
146 ``` 153 ```
147 154
148 ### Get.putAsync 155 ### Get.putAsync
149 156
  157 +Since `Get.put()` does not support async methods/classes, you need to use Get.putAsync. The way of declare is equal to Get.lazyPut
  158 +
150 ```dart 159 ```dart
151 Get.putAsync<S>( 160 Get.putAsync<S>(
152 161
153 // mandatory: an async method that will be executed to instantiate your class 162 // mandatory: an async method that will be executed to instantiate your class
154 - // Example: Get.putAsync<YourAsyncClass>( () async => await YourAsyncClass() )  
155 AsyncInstanceBuilderCallback<S> builder, 163 AsyncInstanceBuilderCallback<S> builder,
156 164
157 // optional: same as Get.put(), it is used for when you want multiple different instance of a same class 165 // optional: same as Get.put(), it is used for when you want multiple different instance of a same class
@@ -161,10 +169,16 @@ Get.putAsync<S>( @@ -161,10 +169,16 @@ Get.putAsync<S>(
161 // optional: same as in Get.put(), used when you need to maintain that instance alive in the entire app 169 // optional: same as in Get.put(), used when you need to maintain that instance alive in the entire app
162 // defaults to false 170 // defaults to false
163 bool permanent = false 171 bool permanent = false
  172 +)
  173 +
  174 +// Example
  175 +Get.putAsync<YourAsyncClass>( () async => await YourAsyncClass() )
164 ``` 176 ```
165 177
166 ### Get.create 178 ### Get.create
167 179
  180 +This one is tricky. A detailed explanation of what this is and the differences between the other one can be found on [Differences between methods:](#differences-between-methods) section
  181 +
168 ```dart 182 ```dart
169 Get.create<S>( 183 Get.create<S>(
170 // required: a function that returns a class that will be "fabricated" every 184 // required: a function that returns a class that will be "fabricated" every
@@ -184,7 +198,7 @@ Get.create<S>( @@ -184,7 +198,7 @@ Get.create<S>(
184 bool permanent = true 198 bool permanent = true
185 ``` 199 ```
186 200
187 -## Diferences between methods: 201 +## Differences between methods
188 202
189 First, let's of the `fenix` of Get.lazyPut and the `permanent` of the other methods. 203 First, let's of the `fenix` of Get.lazyPut and the `permanent` of the other methods.
190 204
@@ -217,9 +231,7 @@ In addition, the Binding class will allow you to have SmartManager configuration @@ -217,9 +231,7 @@ In addition, the Binding class will allow you to have SmartManager configuration
217 - Create a class and implements Binding 231 - Create a class and implements Binding
218 232
219 ```dart 233 ```dart
220 -class HomeBinding implements Bindings {  
221 -  
222 -} 234 +class HomeBinding implements Bindings {}
223 ``` 235 ```
224 236
225 Your IDE will automatically ask you to override the "dependencies" method, and you just need to click on the lamp, override the method, and insert all the classes you are going to use on that route: 237 Your IDE will automatically ask you to override the "dependencies" method, and you just need to click on the lamp, override the method, and insert all the classes you are going to use on that route:
@@ -228,7 +240,7 @@ Your IDE will automatically ask you to override the "dependencies" method, and y @@ -228,7 +240,7 @@ Your IDE will automatically ask you to override the "dependencies" method, and y
228 class HomeBinding implements Bindings { 240 class HomeBinding implements Bindings {
229 @override 241 @override
230 void dependencies() { 242 void dependencies() {
231 - Get.lazyPut<ControllerX>(() => ControllerX()); 243 + Get.lazyPut<HomeController>(() => HomeController());
232 Get.put<Service>(()=> Api()); 244 Get.put<Service>(()=> Api());
233 } 245 }
234 } 246 }
@@ -328,12 +340,15 @@ With the default behavior, even widgets instantiated with "Get.put" will be remo @@ -328,12 +340,15 @@ With the default behavior, even widgets instantiated with "Get.put" will be remo
328 340
329 #### SmartManagement.keepFactory 341 #### SmartManagement.keepFactory
330 342
331 -// TODO ASK JONATAS WHAT THE HECK HE MEANT WITH THIS TEXT  
332 -This one is like SmartManagement.full, with one difference: SmartManagement.full purges the factories from the premises, so that Get.lazyPut() will only be able to be called once and your factory and references will be self-destructing. SmartManagement.keepFactory will remove its dependencies when necessary, however, it will keep the "shape" of these, to make an equal one if you need an instance of that again. 343 +Just like SmartManagement.full, it will remove it's dependencies when it's not being used anymore. However, it will keep the their factory, which means it will recreate the dependency if you need that instance again.
333 344
334 -Instead of using SmartManagement.keepFactory you can use Bindings.  
335 -// TODO ASK JONATAS THIS TOO  
336 -Bindings creates transitory factories, which are created the moment you click to go to another screen, and will be destroyed as soon as the screen-changing animation happens. It is so little time that the analyzer will not even be able to register it. When you navigate to this screen again, a new temporary factory will be called, so this is preferable to using SmartManagement.keepFactory, but if you don't want to create Bindings, or want to keep all your dependencies on the same Binding, it will certainly help you . Factories take up little memory, they don't hold instances, but a function with the "shape" of that class you want. This is very little, but since the purpose of this lib is to get the maximum performance possible using the minimum resources, Get removes even the factories by default. Use whichever is most convenient for you. 345 +### How bindings work under the hood
  346 +Bindings creates transitory factories, which are created the moment you click to go to another screen, and will be destroyed as soon as the screen-changing animation happens.
  347 +This happens so fast that the analyzer will not even be able to register it.
  348 +When you navigate to this screen again, a new temporary factory will be called, so this is preferable to using SmartManagement.keepFactory, but if you don't want to create Bindings, or want to keep all your dependencies on the same Binding, it will certainly help you.
  349 +Factories take up little memory, they don't hold instances, but a function with the "shape" of that class you want.
  350 +This has a very low cost in memory, but since the purpose of this lib is to get the maximum performance possible using the minimum resources, Get removes even the factories by default.
  351 +Use whichever is most convenient for you.
337 352
338 ## Notes 353 ## Notes
339 354