import 'dart:async';

import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_profile_model.dart';
import 'package:zhiying_comm/util/base_bloc.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class MineHeaderBloc extends BlocBase {
  MineProfileModel _profile;

  StreamController<MineProfileModel> _profileController =
      StreamController<MineProfileModel>();

  Stream<MineProfileModel> get outData => _profileController.stream;

  @override
  void dispose() {
    _profileController.close();
    _profileController = null;
  }

  void loadData() {
    NetUtil.request('/api/v1/user/profile',
        method: NetMethod.GET, onCache: (data) {}, onSuccess: (data) {
      _profile = MineProfileModel.fromJson(Map<String, dynamic>.from(data));
      _profileController.add(_profile);
    });
  }
}
