package com.stolets.rxdiffutil.diffrequest;

import android.support.annotation.NonNull;

import com.stolets.rxdiffutil.di.FragmentScope;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import static com.stolets.rxdiffutil.internal.Preconditions.checkNotNull;

/**
 * Manages the diff requests lifecycle.
 */
@FragmentScope
public final class DiffRequestManager {
    @NonNull
    private Map<String, DiffRequest> mPendingRequests = new HashMap<>();
    @NonNull
    private Map<String, Disposable> mCurrentSubscriptions = new HashMap<>();
    @NonNull
    private CompositeDisposable mCompositeDisposable = new CompositeDisposable();

    /**
     * Adds a new {@link DiffRequest} to the pending list.
     * @param diffRequest A new {@link DiffRequest}.
     *                    Note: if a request with the same tag is already exists it will be replaced.
     */
    void addPendingRequest(@NonNull final DiffRequest diffRequest) {
        checkNotNull(diffRequest, "diffRequest must not be null!");
        mPendingRequests.put(diffRequest.getTag(), diffRequest);
    }

    /**
     * @return A map holding all pending requests. Note: the returned map is unmodifiable.
     */
    @NonNull
    Map<String, DiffRequest> getPendingRequests() {
        return Collections.unmodifiableMap(mPendingRequests);
    }
}

@@ -660,16 +660,734 @@
 ble();%0A%0A
+    /**%0A     * Returns a new %7B@link Single%7D that emits the %7B@link RxDiffResult%7D.%0A     *%0A     * @param diffRequest %7B@link DiffRequest%7D holding all parameters to start the difference calculation.%0A     * @return %7B@link Single%7D.%0A     */%0A    private static Single%3CRxDiffResult%3E single(@NonNull final DiffRequest diffRequest) %7B%0A        return Single.fromCallable(new Callable%3CRxDiffResult%3E() %7B%0A            @Override%0A            public RxDiffResult call() throws Exception %7B%0A                final DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(diffRequest.getDiffCallback(), diffRequest.isDetectingMoves());%0A                return new RxDiffResult(diffRequest.getTag(), diffResult);%0A            %7D%0A        %7D);%0A    %7D%0A%0A
     /**%0A
@@ -1445,16 +1445,23 @@
 g list.%0A
+     *%0A
      * @

Add single private static method