package org.mercury_im.messenger.data.repository;

import org.mercury_im.messenger.util.ThreadUtils;

import javax.inject.Named;

import io.reactivex.Scheduler;
import io.requery.Persistable;
import io.requery.reactivex.ReactiveEntityStore;

public abstract class RequeryRepository {

    private final Scheduler subscriberScheduler;
    private final Scheduler observerScheduler;

    private final ReactiveEntityStore<Persistable> data;

    protected RequeryRepository(ReactiveEntityStore<Persistable> data,
                                @Named(value = ThreadUtils.SCHEDULER_IO) Scheduler subscriberScheduler,
                                @Named(value = ThreadUtils.SCHEDULER_UI) Scheduler observerScheduler) {
        this.data = data;
        this.subscriberScheduler = subscriberScheduler;
        this.observerScheduler = observerScheduler;
    }

    protected ReactiveEntityStore<Persistable> data() {
        return data;
    }

    protected Scheduler subscriberScheduler() {
        return subscriberScheduler;
    }

    protected Scheduler observerScheduler() {
        return observerScheduler;
    }

}
