Showing
1 changed file
with
22 additions
and
26 deletions
| @@ -610,24 +610,24 @@ ObxValue((data) => Switch( | @@ -610,24 +610,24 @@ ObxValue((data) => Switch( | ||
| 610 | ), | 610 | ), |
| 611 | ``` | 611 | ``` |
| 612 | 612 | ||
| 613 | -## Useful tips | 613 | +## Полезные советы |
| 614 | 614 | ||
| 615 | -`.obs`ervables (also known as _Rx_ Types) have a wide variety of internal methods and operators. | 615 | +`.obs`ervables (наблюдатели) (также известные как Rx-типы) имеют широкий спектр внутренних методов и операторов |
| 616 | 616 | ||
| 617 | -> Is very common to _believe_ that a property with `.obs` **IS** the actual value... but make no mistake! | ||
| 618 | -> We avoid the Type declaration of the variable, because Dart's compiler is smart enough, and the code | ||
| 619 | -> looks cleaner, but: | 617 | +> Очень распространено _мнение_, что свойство с `.obs` **ЯВЛЯЕТСЯ** действительным значением... но не ошибайтесь! |
| 618 | +> Мы избегаем объявления типа переменной, потому что компилятор Dart достаточно умен, и | ||
| 619 | +> код выглядит чище, но: | ||
| 620 | 620 | ||
| 621 | ```dart | 621 | ```dart |
| 622 | var message = 'Hello world'.obs; | 622 | var message = 'Hello world'.obs; |
| 623 | print( 'Message "$message" has Type ${message.runtimeType}'); | 623 | print( 'Message "$message" has Type ${message.runtimeType}'); |
| 624 | ``` | 624 | ``` |
| 625 | 625 | ||
| 626 | -Even if `message` _prints_ the actual String value, the Type is **RxString**! | 626 | +Даже если `message` _выводит_ значение String, его тип - **RxString**! |
| 627 | 627 | ||
| 628 | -So, you can't do `message.substring( 0, 4 )`. | ||
| 629 | -You have to access the real `value` inside the _observable_: | ||
| 630 | -The most "used way" is `.value`, but, did you know that you can also use... | 628 | +Итак, вы не сможете сделать `message.substring( 0, 4 )`. |
| 629 | +Вы должны получить доступ к реальному `value` внутри _observable_: | ||
| 630 | +Самый "используемый способ" это `.value`, но, знаете ли вы, что вы также можете использовать ... | ||
| 631 | 631 | ||
| 632 | ```dart | 632 | ```dart |
| 633 | final name = 'GetX'.obs; | 633 | final name = 'GetX'.obs; |
| @@ -718,9 +718,9 @@ print( user ); | @@ -718,9 +718,9 @@ print( user ); | ||
| 718 | 718 | ||
| 719 | #### GetView | 719 | #### GetView |
| 720 | 720 | ||
| 721 | -I love this Widget, is so simple, yet, so useful! | 721 | +Я люблю этот виджет, он такой простой, но такой полезный! |
| 722 | 722 | ||
| 723 | -Is a `const Stateless` Widget that has a getter `controller` for a registered `Controller`, that's all. | 723 | +Это`const Stateless` виджет, который имеет геттер `controller` для зарегистрированного `Controller`, вот и всё. |
| 724 | 724 | ||
| 725 | ```dart | 725 | ```dart |
| 726 | class AwesomeController extends GetxController { | 726 | class AwesomeController extends GetxController { |
| @@ -741,27 +741,25 @@ Is a `const Stateless` Widget that has a getter `controller` for a registered `C | @@ -741,27 +741,25 @@ Is a `const Stateless` Widget that has a getter `controller` for a registered `C | ||
| 741 | 741 | ||
| 742 | #### GetWidget | 742 | #### GetWidget |
| 743 | 743 | ||
| 744 | -Most people have no idea about this Widget, or totally confuse the usage of it. | ||
| 745 | -The use case is very rare, but very specific: It `caches` a Controller. | ||
| 746 | -Because of the _cache_, can't be a `const Stateless`. | 744 | +Большинство людей понятия не имеют об этом виджете или путаются при его применении. |
| 745 | +Вариант его использования редок, но конкретен: он кеширует Controller. | ||
| 746 | +Так как из-за _cache_, он не может быть `const Stateless`. | ||
| 747 | 747 | ||
| 748 | -> So, when do you need to "cache" a Controller? | 748 | +> Итак, когда вам нужно «кэшировать» контроллер? |
| 749 | 749 | ||
| 750 | -If you use, another "not so common" feature of **GetX**: `Get.create()`. | 750 | +В случаях использования другой "не распространённой" фичи **GetX**: `Get.create()`. |
| 751 | 751 | ||
| 752 | -`Get.create(()=>Controller())` will generate a new `Controller` each time you call | 752 | +`Get.create(()=>Controller())` будет создавать новый `Controller` каждый раз при вызове |
| 753 | `Get.find<Controller>()`, | 753 | `Get.find<Controller>()`, |
| 754 | 754 | ||
| 755 | -That's where `GetWidget` shines... as you can use it, for example, | ||
| 756 | -to keep a list of Todo items. So, if the widget gets "rebuilt", it will keep the same controller instance. | 755 | +Это тот самый случай, когда `GetWidget` блистает... поскольку вы можете использовать его, например, для хранения списка элементов Todo. Итак, если виджет будет «перестроен», он сохранит тот же экземпляр контроллера. |
| 757 | 756 | ||
| 758 | #### GetxService | 757 | #### GetxService |
| 759 | 758 | ||
| 760 | -This class is like a `GetxController`, it shares the same lifecycle ( `onInit()`, `onReady()`, `onClose()`). | ||
| 761 | -But has no "logic" inside of it. It just notifies **GetX** Dependency Injection system, that this subclass | ||
| 762 | -**can not** be removed from memory. | 759 | +Этот класс похожа на `GetxController`, у него такой же жизненный цикл ( `onInit()`, `onReady()`, `onClose()`). |
| 760 | +Но внутри нет никакой «логики». Он просто уведомляет систему **GetX** Dependency Injection о том, что этот подкласс **нельзя** удалить из памяти. | ||
| 763 | 761 | ||
| 764 | -So is super useful to keep your "Services" always reachable and active with `Get.find()`. Like: | 762 | +Так что очень полезно держать ваши «Сервисы» всегда доступными и активными с помощью `Get.find()`. Например: |
| 765 | `ApiService`, `StorageService`, `CacheService`. | 763 | `ApiService`, `StorageService`, `CacheService`. |
| 766 | 764 | ||
| 767 | ```dart | 765 | ```dart |
| @@ -802,9 +800,7 @@ class SettingsService extends GetxService { | @@ -802,9 +800,7 @@ class SettingsService extends GetxService { | ||
| 802 | 800 | ||
| 803 | ``` | 801 | ``` |
| 804 | 802 | ||
| 805 | -The only way to actually delete a `GetxService`, is with `Get.reset()` which is like a | ||
| 806 | -"Hot Reboot" of your app. So remember, if you need absolute persistance of a class instance during the | ||
| 807 | -lifetime of your app, use `GetxService`. | 803 | +Единственный способ удалить `GetxService` - использовать `Get.reset()`, который похож на «горячую перезагрузку» вашего приложения. Так что помните, если вам нужен постоянный экземпляр класса в течение всего жизненного цикла вашего приложения, используйте `GetxService`. |
| 808 | 804 | ||
| 809 | # Breaking changes from 2.0 | 805 | # Breaking changes from 2.0 |
| 810 | 806 |
-
Please register or login to post a comment