package com.a2i.forwarder

import android.app.Application
import com.a2i.forwarder.core.LogStore
import com.a2i.forwarder.store.AppRulesStore
import com.a2i.forwarder.store.SettingsStore
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob

class A2iApp : Application() {
    val appScope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)

    lateinit var settings: SettingsStore
        private set
    lateinit var appRules: AppRulesStore
        private set
    lateinit var logStore: LogStore
        private set

    override fun onCreate() {
        super.onCreate()
        instance = this
        settings = SettingsStore(this, appScope)
        appRules = AppRulesStore(this, appScope)
        logStore = LogStore(this, appScope)
    }

    companion object {
        lateinit var instance: A2iApp
            private set
    }
}
