Interface Store
-
- All Superinterfaces:
- Dispatcher, GetState
public interface Store extends GetState, Dispatcher
TheStorecontains the application's state, reducer logic, middleware and listeners.Staterepresents the application state. The state is partition into state keys.Reducerrepresents the logic to update theState. A reducer provides the functionality to update the state for a particularAction.Middlewareis a function that intercepts anActionand can enrich or alter it before reaching theReducer.Listenera function that gets called on state changes
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description SubscriptionaddActionListener(Listener<Action<?>> actionListener)Adds a newListenerto the store.<E> SubscriptionaddListener(java.lang.Class<E> clazz, Filter<E> filter, Listener<E> listener)Adds a newListenerto the store.<E> SubscriptionaddListener(java.lang.Class<E> clazz, Listener<E> listener)Adds a newListenerto the store.SubscriptionaddListener(Filter<State> filter, Listener<State> listener)Adds a newListenerto the store.<E> SubscriptionaddListener(Filter<State> filter, StateSelector<E> stateSelector, Listener<E> listener)Adds a newListenerto the store.SubscriptionaddListener(Listener<State> listener)Adds a newListenerto the store.<E> SubscriptionaddListener(StateSelector<E> stateSelector, Listener<E> listener)Adds a newListenerto the store.<E> SubscriptionaddListener(java.lang.String stateKey, java.lang.Class<E> clazz, Filter<E> filter, Listener<E> listener)Adds a newListenerto the store.<E> SubscriptionaddListener(java.lang.String stateKey, java.lang.Class<E> clazz, Listener<E> listener)Adds a newListenerto the store.<E> SubscriptionaddListener(java.lang.String stateKey, Filter<E> filter, Listener<E> listener)Adds a newListenerto the store.<E> SubscriptionaddListener(java.lang.String stateKey, Listener<E> listener)Adds a newListenerto the store.voidremoveListener(Listener<?> listener)Remove a listener from the store.voidreset(State state)Resets the full internal state with a new state and notifies all registeredListener-
Methods inherited from interface zendesk.support.suas.Dispatcher
dispatch
-
-
-
-
Method Detail
-
reset
void reset(State state)
Resets the full internal state with a new state and notifies all registeredListener- Parameters:
state- the new state
-
addListener
Subscription addListener(Listener<State> listener)
Adds a newListenerto the store.The provided
Listenerwill be notified on any state changes. If nothing else providedFilters.DEFAULTwill be used to decide whether to notify or not.- Parameters:
listener- callback to be notified on state changes- Returns:
- a subscription for managing the listener's lifecycle
-
addListener
Subscription addListener(Filter<State> filter, Listener<State> listener)
Adds a newListenerto the store.The provided
Listenerwill be notified on any state changes. The providedFilteris used to decide whether to notify or not.- Parameters:
filter- function used to decide whether to notify or notlistener- callback to be notified on state changes- Returns:
- a subscription for managing the listener's lifecycle
-
addListener
<E> Subscription addListener(StateSelector<E> stateSelector, Listener<E> listener)
Adds a newListenerto the store.The provided
Listenerwill be notified on any state changes. If the provided typeEdoesn't match the object behind the passed inkeythe listener will never be notified and a warning will be logged.
If nothing else providedFilters.DEFAULTwill be used to decide whether to notify or not.- Type Parameters:
E- type of the returned object of the state selector- Parameters:
stateSelector- function for convertingStateto an object of type<E>listener- callback to be notified on state changes- Returns:
- a subscription for managing the listener's lifecycle
-
addListener
<E> Subscription addListener(Filter<State> filter, StateSelector<E> stateSelector, Listener<E> listener)
Adds a newListenerto the store.The provided
Listenerwill be notified on any state changes. If the provided typeEdoesn't match the object behind the passed inkeythe listener will never be notified and a warning will be logged.
If nothing else providedFilters.DEFAULTwill be used to decide whether to notify or not.- Type Parameters:
E- type of the returned object of the state selector- Parameters:
filter- function used to decide whether to notify or notstateSelector- function for convertingStateto an object of type<E>listener- callback to be notified on state changes- Returns:
- a subscription for managing the listener's lifecycle
-
addListener
<E> Subscription addListener(java.lang.String stateKey, Listener<E> listener)
Adds a newListenerto the store.The provided
Listenerwill be notified on any changes to the part state that's tied to the passed in key. If the provided typeEdoesn't match the object behind the passed inkeythe listener will never be notified and a warning will be logged.
If nothing else providedFilters.DEFAULTwill be used to decide whether to notify or not.- Type Parameters:
E- type of the state that's registered on the providedkey- Parameters:
stateKey- the state key to listen for changeslistener- callback to be notified on state changes- Returns:
- a subscription for managing the listener's lifecycle
-
addListener
<E> Subscription addListener(java.lang.String stateKey, Filter<E> filter, Listener<E> listener)
Adds a newListenerto the store.The provided
Listenerwill be notified on any changes to the part state that's tied to the passed in key. If the provided typeEdoesn't match the object behind the passed inkeythe listener will never be notified and a warning will be logged.
The providedFilteris used to decide whether to notify or not.- Type Parameters:
E- type of the state that's registered on the providedkey- Parameters:
stateKey- the state key to listen for changesfilter- function used to decide whether to notify or notlistener- callback to be notified on state changes- Returns:
- a subscription for managing the listener's lifecycle
-
addListener
<E> Subscription addListener(java.lang.Class<E> clazz, Listener<E> listener)
Adds a newListenerto the store.The provided
Listenerwill be notified on any changes to the part state that's tied to the passed inClass. If the provided typeEdoesn't match the object behind the passed inclassthe listener will never be notified and a warning will be logged.
If nothing else providedFilters.DEFAULTwill be used to decide whether to notify or not.- Type Parameters:
E- type of the state that's registered on the providedkey- Parameters:
clazz- the state key and type listen for changeslistener- callback to be notified on state changes- Returns:
- a subscription for managing the listener's lifecycle
-
addListener
<E> Subscription addListener(java.lang.Class<E> clazz, Filter<E> filter, Listener<E> listener)
Adds a newListenerto the store.The provided
Listenerwill be notified on any changes to the part state that's tied to the passed inClass. If the provided typeEdoesn't match the object behind the passed inclassthe listener will never be notified and a warning will be logged.
The providedFilteris used to decide whether to notify or not.- Type Parameters:
E- type of the state that's registered on the providedclazz- Parameters:
clazz- the state key and type to listen for changesfilter- function used to decide whether to notify or notlistener- callback to be notified on state changes- Returns:
- a subscription for managing the listener's lifecycle
-
addListener
<E> Subscription addListener(java.lang.String stateKey, java.lang.Class<E> clazz, Listener<E> listener)
Adds a newListenerto the store.The provided
Listenerwill be notified on any changes to the part state that's tied to the passed inkeyand of typeclazz. If the provided typeEdoesn't match the object behind the passed inkeythe listener will never be notified and a warning will be logged.
If nothing else providedFilters.DEFAULTwill be used to decide whether to notify or not.- Type Parameters:
E- type of the state that's registered on the providedkey- Parameters:
stateKey- the state key to listen for changesclazz- the state type to listen for changeslistener- callback to be notified on state changes- Returns:
- a subscription for managing the listener's lifecycle
-
addListener
<E> Subscription addListener(java.lang.String stateKey, java.lang.Class<E> clazz, Filter<E> filter, Listener<E> listener)
Adds a newListenerto the store.The provided
Listenerwill be notified on any changes to the part state that's tied to the passed inkeyand of typeclazz. If the provided typeEdoesn't match the object behind the passed inkeythe listener will never be notified and a warning will be logged.
The providedFilteris used to decide whether to notify or not.- Type Parameters:
E- type of the state that's registered on the providedkey- Parameters:
stateKey- the state key to listen for changesclazz- the state type to listen for changesfilter- function used to decide whether to notify or notlistener- callback to be notified on state changes- Returns:
- a subscription for managing the listener's lifecycle
-
addActionListener
Subscription addActionListener(Listener<Action<?>> actionListener)
Adds a newListenerto the store.Action listeners will be notified whenever a new action is dispatched. Inside the action notification you cast to the specific action and read the payload of the action.
- Parameters:
actionListener- callback to be notified when an action happens.- Returns:
- a subscription for managing the listener's lifecycle
-
removeListener
void removeListener(Listener<?> listener)
Remove a listener from the store.- Parameters:
listener- the listener to remove
-
-