package com.ycgis.macall.personalcenter.p.rxjava;

import org.jetbrains.annotations.NotNull;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

/**
 * created by:   Macall
 * create time:  2023/11/20 14:21
 * copyright:    @ruansee.com
 * Describe:
 */
public abstract class ResultObserver<T>  implements Observer<T> {
    private String identifierKey;

    public ResultObserver(String identifierKey) {
        this.identifierKey = identifierKey;
    }

    protected abstract void onNext(String identifierKey,@NotNull T data);

    protected  void onSubscribe(String identifierKey, @NotNull Disposable d) {

    }
    protected  void onError(String identifierKey, @NotNull Throwable  data){

    }
    protected  void onComplete(String identifierKey){

    }

    @Override
    public void onSubscribe(@NotNull Disposable d) {
        onSubscribe(identifierKey,d);
    }

    @Override
    public void onNext(@NotNull T o) {
        onNext(identifierKey,o);
    }

    @Override
    public void onError(@NotNull Throwable e) {
        onError(identifierKey,e);
            
    }

    @Override
    public void onComplete() {
        onComplete(identifierKey);
    }
}
