Skip to content

Commit a859c62

Browse files
committed
chore: simplifying the dataservice - WIP
1 parent 3b2375c commit a859c62

File tree

8 files changed

+8
-10
lines changed

8 files changed

+8
-10
lines changed

lib/binding/initial_binding.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class InitialBinding extends Bindings {
1212
@override
1313
void dependencies() {
1414
logger.i("InitialBinding");
15-
Get.put<DataService>(DataService());
15+
Get.put<DataServiceV1>(DataServiceV1());
1616
Get.put<DataService2>(DataService2());
1717
Get.put<UserDataProfileControllerV1>(UserDataProfileControllerV1());
1818
Get.put<UserDataProfileControllerV2>(UserDataProfileControllerV2());

lib/building_block_getx.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class MyApp extends StatelessWidget {
2525
),
2626
getPages: [
2727
GetPage(name: "/home", page: () => HomeScreen(), binding: HomeBinding()),
28-
GetPage(name: "/detail", page: () => DetailScreen(), binding: DetailBinding()),
28+
GetPage(name: "/detail", page: () => DetailScreenV2(), binding: DetailBinding()),
2929
],
3030
initialRoute: "/home",
3131
);

lib/controller/user_data_profile.controller_v1.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:getx_websocket_example/model/user-data-profile.entity.dart';
33
import 'package:getx_websocket_example/services/data.service.dart';
44

55
class UserDataProfileControllerV1 extends GetxController with StateMixin<UserDataProfile> {
6-
final dataService = Get.find<DataService>();
6+
final dataService = Get.find<DataServiceV1>();
77
Worker getxWorker;
88

99
void fetchData() {

lib/controller/user_data_profile.controller_v2.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class UserDataProfileControllerV2 extends GetxController {
99

1010
final Rx<UserDataProfile> userProfileData = UserDataProfile().obs;
1111
final Rx<Status> status = Status.loading.obs;
12-
final DataService _dataService = Get.find<DataService>();
12+
final DataServiceV1 _dataService = Get.find<DataServiceV1>();
1313

1414
void fetchUserDataProfile() {
1515
_getxWorker = ever(_dataService.fetchUserDataProfile(), (_profile) {

lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class MyApp extends StatelessWidget {
2525
),
2626
getPages: [
2727
GetPage(name: "/home", page: () => HomeScreen(), binding: HomeBinding()),
28-
GetPage(name: "/detail", page: () => DetailScreen(), binding: DetailBinding()),
28+
GetPage(name: "/detail", page: () => DetailScreenV2(), binding: DetailBinding()),
2929
],
3030
initialRoute: "/home",
3131
);

lib/services/data.service.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ import 'logging.service.dart';
1010

1111
enum Status { loading, error, success }
1212

13-
class DataService extends GetxService {
13+
class DataServiceV1 extends GetxService {
1414
WebSocketChannel _channel;
1515

1616
final _logger = LoggingService().logger;
1717
final Rx<UserDataProfile> _userDataProfile = UserDataProfile().obs;
18-
final Rx<Status> _userDataProfileStatus = Status.loading.obs;
1918

2019
final ObserverList<Function> _listeners = new ObserverList<Function>();
2120
final LinkedHashSet _listenerSet = new LinkedHashSet();
@@ -24,7 +23,6 @@ class DataService extends GetxService {
2423
Function _fetchUserDataProfileCallback = (Map<String, dynamic> _messageEventMap, String _uuid) {
2524
if (_messageEventMap['event'] == '/identity/$_uuid') {
2625
_userDataProfile(UserDataProfile.fromJson(_messageEventMap['data']));
27-
_userDataProfileStatus(Status.success);
2826
_logger.d('---------------userProfile.1: ${_userDataProfile.value.uuid}');
2927
}
3028
};

lib/view/detail.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:get/get.dart';
33
import 'package:getx_websocket_example/services/data.service_v2.dart';
44
import 'package:getx_websocket_example/services/logging.service.dart';
55

6-
class DetailScreen extends GetWidget<DataService2> {
6+
class DetailScreenV2 extends GetWidget<DataService2> {
77
final logger = LoggingService().logger;
88

99
@override

lib/view/home.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class HomeScreen extends StatelessWidget {
3939
onPressed: () {
4040
// print(dataService.fetchData());
4141
//homeController.increment();
42-
Get.to(() => DetailScreen());
42+
Get.to(() => DetailScreenV2());
4343
},
4444
child: Text("Go to details page"),
4545
color: Colors.red,

0 commit comments

Comments
 (0)