Skip to content

Instantly share code, notes, and snippets.

@pardom-zz
Last active October 12, 2016 20:07
Show Gist options
  • Save pardom-zz/12548b1a4dab4723fb433a0eb629831e to your computer and use it in GitHub Desktop.
Save pardom-zz/12548b1a4dab4723fb433a0eb629831e to your computer and use it in GitHub Desktop.
JVM Redux API
interface Dispatcher {
Object dispatch(Object action);
}
interface Middleware<S> {
Object dispatch(Store<S> store, Object action, Dispatcher next);
}
interface Reducer<S> {
S reduce(S state, Object action);
}
interface Store<S> extends Dispatcher {
S getState();
Subscription subscribe(Subscriber subscriber);
void replaceReducer(Reducer<S> reducer);
interface Creator<S> {
Store<S> create(Reducer<S> reducer, S initialState, Enhancer<S> enhancer);
}
interface Enhancer<S> {
Creator<S> enhance(Creator<S> next);
}
interface Subscriber {
void onStateChanged();
}
interface Subscription {
void unsubscribe();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment