Newer
Older
RxFlux / app / src / main / java / j4ckall / rxflux / ui / MainStore.java
KeijuMatsumoto on 2 Dec 2017 720 bytes [add] Counter
package j4ckall.rxflux.ui;

import j4ckall.rxflux.App;
import j4ckall.rxflux.lib.flux.Store;

/**
 * MainActivityの状態を保持するクラス
 *
 * @author matsumoto_k
 */
public class MainStore extends Store {

    private int count;
    private boolean initialize = false;

    public MainStore() {
        super(App.getDispatcher());

        on(MainAction.COUNT_UP, action -> {
            count += (Integer) action.value;
        });

        on(MainAction.COUNT_DOWN, action -> {
            count -= (Integer) action.value;
        });

        on(MainAction.INITIALIZE, action -> {
            count = (Integer) action.value;
        });
    }

    public Integer getCount() {
        return count;
    }
}