TF-474 Use Ever/Worker to listen Obx object
This commit is contained in:
@@ -121,7 +121,10 @@ class ManageAccountDashBoardView extends GetWidget<ManageAccountDashBoardControl
|
||||
..addOnTapAvatarActionWithPositionClick((position) =>
|
||||
controller.openPopupMenuAction(context, position, popupMenuUserSettingActionTile(context,
|
||||
controller.userProfile.value,
|
||||
onLogoutAction: () => controller.logoutAction(),
|
||||
onLogoutAction: () {
|
||||
popBack();
|
||||
controller.logoutAction();
|
||||
},
|
||||
onSettingAction: () {
|
||||
popBack();
|
||||
controller.goToSettings();
|
||||
|
||||
+16
-5
@@ -45,6 +45,8 @@ class IdentitiesController extends BaseController {
|
||||
|
||||
final idIdentityAll = IdentityId(Id('all'));
|
||||
|
||||
late Worker accountIdWorker;
|
||||
|
||||
IdentitiesController(
|
||||
this._getAllIdentitiesInteractor,
|
||||
this._deleteIdentityInteractor,
|
||||
@@ -55,10 +57,16 @@ class IdentitiesController extends BaseController {
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
_onAccountDashBoardListener();
|
||||
_initWorker();
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
_clearWorker();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@override
|
||||
void onDone() {
|
||||
viewState.value.fold(
|
||||
@@ -91,15 +99,18 @@ class IdentitiesController extends BaseController {
|
||||
void onError(error) {
|
||||
}
|
||||
|
||||
void _onAccountDashBoardListener() {
|
||||
_accountDashBoardController.accountId.listen((accountId) {
|
||||
log('IdentitiesController::_onAccountDashBoardListener(): accountId: $accountId');
|
||||
if (accountId != null) {
|
||||
void _initWorker() {
|
||||
accountIdWorker = ever(_accountDashBoardController.accountId, (accountId) {
|
||||
if (accountId is AccountId) {
|
||||
_getAllIdentities(accountId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _clearWorker() {
|
||||
accountIdWorker.call();
|
||||
}
|
||||
|
||||
void _getAllIdentities(AccountId accountId) {
|
||||
consumeState(_getAllIdentitiesInteractor.execute(accountId));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user