package net.pokeranalytics.android.ui.fragment.components

import io.realm.Realm
import io.realm.RealmResults
import net.pokeranalytics.android.model.realm.ComputableResult

open class SessionObserverFragment : PokerAnalyticsFragment() {

    val endedSessions: RealmResults<ComputableResult>

    init {
        val realm = Realm.getDefaultInstance()
        this.endedSessions = realm.where(ComputableResult::class.java).isNotNull("session.endDate").findAll()
        this.endedSessions.addChangeListener { _, _ ->
            this.sessionsChanged()
        }
    }

    open fun sessionsChanged() {
        // to override
    }

}