Newer
Older
RxFlux / app / src / main / java / j4ckall / rxflux / lib / flux / ActionCreater.java
KeijuMatsumoto on 2 Dec 2017 932 bytes [add] Flux base
package j4ckall.rxflux.lib.flux;


import android.support.annotation.NonNull;

/**
 * Actionを作成するHelper
 * DispatcherにActionを流す
 *
 * @author matsumoto_k
 */
public abstract class ActionCreater {

    private final Dispatcher dispatcher;

    public ActionCreater(Dispatcher dispatcher) {
        this.dispatcher = dispatcher;
    }

    /**
     * DispatcherにActionを流す(通知有)
     *
     * @param key   Action識別子
     * @param value
     * @param <T>
     */
    protected final <T> void dispatch(@NonNull Action.Key key, @NonNull T value) {
        dispatcher.dispatch(new Action(key, value, true));
    }

    /**
     * DispatcherにActionを流す(通知無)
     *
     * @param key
     * @param value
     * @param <T>
     */
    protected final <T> void dispatchSkipNotify(@NonNull Action.Key key, @NonNull T value) {
        dispatcher.dispatch(new Action(key, value, false));
    }
}