import 'dart:async';
import 'package:guru_assistant/data/setting.dart';
import 'package:rxdart/rxdart.dart';
import 'package:guru_app/property/settings/guru_settings.dart';
import 'package:guru_utils/controller/controller.dart';
import 'package:guru_utils/property/property.dart';
import 'package:injectable/injectable.dart';
import 'package:guru_utils/controller/aware/controller_aware.dart';
import 'package:guru_utils/controller/ads_controller.dart';
import 'package:guru_app/ads/ads_manager.dart';



class GuruKeywordsTestController extends LifecycleController {
  final BehaviorSubject<Map<String, String>> originKeywords =
      BehaviorSubject.seeded(<String, String>{});

  Stream<Map<String, String>> get observableKeywords => AdsManager.instance.observableKeywords;

  Stream<Map<String, String>> get observableOriginKeywords => originKeywords.stream;

  @override
  void onInit() async {
    super.onInit();
    final currentKeywords = await KeywordsTestSetting.instance.init();
    originKeywords.add(currentKeywords);
  }

  @override
  void onClose() {
    super.onClose();
    AdsManager.instance.restoreKeywords(originKeywords.value);
  }
}