import 'dart:async';

import 'package:zhiying_comm/util/base_bloc.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class MineHeaderBloc extends BlocBase {
  Map<String, dynamic> _mineData;

  StreamController<Map<String, dynamic>> _mineController =
      StreamController<Map<String, dynamic>>();

  Stream<Map<String, dynamic>> get outData => _mineController.stream;

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

  void loadData(int id) {
    NetUtil.request('/api/v1/mod',
        method: NetMethod.POST,
        params: Map<String, dynamic>.from({
          'ids': [id]
        }),
        onCache: (data) {}, onSuccess: (data) {
      _loadData(id, data);
    });
  }

  void _loadData(int id, dynamic data) {
    String key = id.toString();
    Map<String, dynamic> json = Map<String, dynamic>.from(data);

    _mineController.add(_mineData);
  }
}
