// Path: redux-core/src/main/java/me/tatarka/redux/Dispatcher.java
// public abstract class Dispatcher<A, R> {
// 
//     /**
//      * Constructs a {@code Dispatcher} from the given {@link Store} and {@link Reducer}. {@link #dispatch(Object)} will
//      * run the action through the reducer and update the store with the resulting state.
//      *
//      * @param <S> The type of state in the store.
//      * @param <A> The type of action.
//      * @return the action dispatched.
//      */
//     public static <S, A> Dispatcher<A, A> forStore(final Store<S> store, final Reducer<A, S> reducer) {
//         if (store == null) {
//             throw new NullPointerException("store==null");
//         }
//         if (reducer == null) {
//             throw new NullPointerException("reducer==null");
//         }
//         return new Dispatcher<A, A>() {
//             @Override
//             public A dispatch(A action) {
//                 store.setState(reducer.reduce(action, store.getState()));
//                 return action;
//             }
//         };
//     }
// 
//     /**
//      * Dispatches the given action.
//      */
//     public abstract R dispatch(A action);
// 
//     /**
//      * Returns a new {@code Dispatcher} that runs the given {@link Middleware}.
//      */
//     public final Dispatcher<A, R> chain(final Middleware<A, R> middleware) {
//         if (middleware == null) {
//             throw new NullPointerException("middleware==null");
//         }
//         return new Dispatcher<A, R>() {
//             @Override
//             public R dispatch(A action) {
//                 return middleware.dispatch(new Middleware.Next<A, R>() {
//                     @Override
//                     public R next(A action) {
//                         return Dispatcher.this.dispatch(action);
//                     }
//                 }, action);
//             }
//         };
//     }
// 
//     /**
//      * Returns a new {@code Dispatcher} that runs the given collection of {@link Middleware}.
//      */
//     public final Dispatcher<A, R> chain(Iterable<Middleware<A, R>> middleware) {
//         return chain(middleware.iterator());
//     }
// 
//     /**
//      * Returns a new {@code Dispatcher} that runs the given collection of {@link Middleware}.
//      */
//     @SafeVarargs
//     public final Dispatcher<A, R> chain(Middleware<A, R>... middleware) {
//         return chain(Arrays.asList(middleware));
//     }
// 
//     private Dispatcher<A, R> chain(Iterator<Middleware<A, R>> itr) {
//         if (!itr.hasNext()) {
//             return this;
//         }
//         return chain(itr.next()).chain(itr);
//     }
// }
// 
// Path: redux-core/src/main/java/me/tatarka/redux/Reducer.java
// public interface Reducer<A, S> {
//     S reduce(A action, S state);
// }
// 
// Path: redux-core/src/main/java/me/tatarka/redux/SimpleStore.java
// public class SimpleStore<S> implements Store<S> {
// 
//     private volatile S state;
//     private final CopyOnWriteArrayList<Listener<S>> listeners = new CopyOnWriteArrayList<>();
// 
//     public SimpleStore(S initialState) {
//         setState(initialState);
//     }
// 
//     @Override
//     public S getState() {
//         return state;
//     }
// 
//     @Override
//     public void setState(S newState) {
//         if (!equals(state, newState)) {
//             state = newState;
//             for (Listener<S> listener : listeners) {
//                 listener.onNewState(state);
//             }
//         }
//     }
// 
//     /**
//      * Registers as listener to receive state changes. The current state will be delivered
//      * immediately.
//      */
//     public void addListener(Listener<S> listener) {
//         listeners.add(listener);
//         listener.onNewState(state);
//     }
// 
//     /**
//      * Removes the listener so it no longer receives state changes.
//      */
//     public void removeListener(Listener<S> listener) {
//         listeners.remove(listener);
//     }
// 
//     public interface Listener<S> {
//         /**
//          * Called when a new state is set. This is called on the same thread as  or {@link #setState(Object)}.
//          */
//         void onNewState(S state);
//     }
// 
//     private static boolean equals(Object var0, Object var1) {
//         return var0 == var1 || var0 != null && var0.equals(var1);
//     }
// }


import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import me.tatarka.redux.Dispatcher;
import me.tatarka.redux.Reducer;
import me.tatarka.redux.SimpleStore;
import rx.Observable;
import rx.Single;
import rx.functions.Action0;
import rx.observers.TestSubscriber;
import static org.junit.Assert.assertTrue;
package me.tatarka.redux.rx;






@RunWith(JUnit4.class)
public class ObservableDispatcherTest {

    @Test
    public void subscription_receives_initial_state() {
        TestSubscriber<String> testSubscriber = new TestSubscriber<>();
// Path: redux-core/src/main/java/me/tatarka/redux/Dispatcher.java
// public abstract class Dispatcher<A, R> {
// 
//     /**
//      * Constructs a {@code Dispatcher} from the given {@link Store} and {@link Reducer}. {@link #dispatch(Object)} will
//      * run the action through the reducer and update the store with the resulting state.
//      *
//      * @param <S> The type of state in the store.
//      * @param <A> The type of action.
//      * @return the action dispatched.
//      */
//     public static <S, A> Dispatcher<A, A> forStore(final Store<S> store, final Reducer<A, S> reducer) {
//         if (store == null) {
//             throw new NullPointerException("store==null");
//         }
//         if (reducer == null) {
//             throw new NullPointerException("reducer==null");
//         }
//         return new Dispatcher<A, A>() {
//             @Override
//             public A dispatch(A action) {
//                 store.setState(reducer.reduce(action, store.getState()));
//                 return action;
//             }
//         };
//     }
// 
//     /**
//      * Dispatches the given action.
//      */
//     public abstract R dispatch(A action);
// 
//     /**
//      * Returns a new {@code Dispatcher} that runs the given {@link Middleware}.
//      */
//     public final Dispatcher<A, R> chain(final Middleware<A, R> middleware) {
//         if (middleware == null) {
//             throw new NullPointerException("middleware==null");
//         }
//         return new Dispatcher<A, R>() {
//             @Override
//             public R dispatch(A action) {
//                 return middleware.dispatch(new Middleware.Next<A, R>() {
//                     @Override
//                     public R next(A action) {
//                         return Dispatcher.this.dispatch(action);
//                     }
//                 }, action);
//             }
//         };
//     }
// 
//     /**
//      * Returns a new {@code Dispatcher} that runs the given collection of {@link Middleware}.
//      */
//     public final Dispatcher<A, R> chain(Iterable<Middleware<A, R>> middleware) {
//         return chain(middleware.iterator());
//     }
// 
//     /**
//      * Returns a new {@code Dispatcher} that runs the given collection of {@link Middleware}.
//      */
//     @SafeVarargs
//     public final Dispatcher<A, R> chain(Middleware<A, R>... middleware) {
//         return chain(Arrays.asList(middleware));
//     }
// 
//     private Dispatcher<A, R> chain(Iterator<Middleware<A, R>> itr) {
//         if (!itr.hasNext()) {
//             return this;
//         }
//         return chain(itr.next()).chain(itr);
//     }
// }
// 
// Path: redux-core/src/main/java/me/tatarka/redux/Reducer.java
// public interface Reducer<A, S> {
//     S reduce(A action, S state);
// }
// 
// Path: redux-core/src/main/java/me/tatarka/redux/SimpleStore.java
// public class SimpleStore<S> implements Store<S> {
// 
//     private volatile S state;
//     private final CopyOnWriteArrayList<Listener<S>> listeners = new CopyOnWriteArrayList<>();
// 
//     public SimpleStore(S initialState) {
//         setState(initialState);
//     }
// 
//     @Override
//     public S getState() {
//         return state;
//     }
// 
//     @Override
//     public void setState(S newState) {
//         if (!equals(state, newState)) {
//             state = newState;
//             for (Listener<S> listener : listeners) {
//                 listener.onNewState(state);
//             }
//         }
//     }
// 
//     /**
//      * Registers as listener to receive state changes. The current state will be delivered
//      * immediately.
//      */
//     public void addListener(Listener<S> listener) {
//         listeners.add(listener);
//         listener.onNewState(state);
//     }
// 
//     /**
//      * Removes the listener so it no longer receives state changes.
//      */
//     public void removeListener(Listener<S> listener) {
//         listeners.remove(listener);
//     }
// 
//     public interface Listener<S> {
//         /**
//          * Called when a new state is set. This is called on the same thread as  or {@link #setState(Object)}.
//          */
//         void onNewState(S state);
//     }
// 
//     private static boolean equals(Object var0, Object var1) {
//         return var0 == var1 || var0 != null && var0.equals(var1);
//     }
// }


// Path: redux-rx/src/test/java/me/tatarka/redux/rx/ObservableDispatcherTest.java
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import me.tatarka.redux.Dispatcher;
import me.tatarka.redux.Reducer;
import me.tatarka.redux.SimpleStore;
import rx.Observable;
import rx.Single;
import rx.functions.Action0;
import rx.observers.TestSubscriber;
import static org.junit.Assert.assertTrue;

package me.tatarka.redux.rx;






@RunWith(JUnit4.class)
public class ObservableDispatcherTest {

    @Test
    public void subscription_receives_initial_state() {
        TestSubscriber<String> testSubscriber = new TestSubscriber<>();
        SimpleStore<String> store = new SimpleStore<>("test1");