Interface Store
-
- All Superinterfaces:
- Dispatcher, GetState
public interface Store extends GetState, Dispatcher
TheStore
contains the application's state, reducer logic, middleware and listeners.State
represents the application state. The state is partition into state keys.Reducer
represents the logic to update theState
. A reducer provides the functionality to update the state for a particularAction
.Middleware
is a function that intercepts anAction
and can enrich or alter it before reaching theReducer
.Listener
a function that gets called on state changes
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description Subscription
addActionListener(Listener<Action<?>> actionListener)
Adds a newListener
to the store.<E> Subscription
addListener(java.lang.Class<E> clazz, Filter<E> filter, Listener<E> listener)
Adds a newListener
to the store.<E> Subscription
addListener(java.lang.Class<E> clazz, Listener<E> listener)
Adds a newListener
to the store.Subscription
addListener(Filter<State> filter, Listener<State> listener)
Adds a newListener
to the store.<E> Subscription
addListener(Filter<State> filter, StateSelector<E> stateSelector, Listener<E> listener)
Adds a newListener
to the store.Subscription
addListener(Listener<State> listener)
Adds a newListener
to the store.<E> Subscription
addListener(StateSelector<E> stateSelector, Listener<E> listener)
Adds a newListener
to the store.<E> Subscription
addListener(java.lang.String stateKey, java.lang.Class<E> clazz, Filter<E> filter, Listener<E> listener)
Adds a newListener
to the store.<E> Subscription
addListener(java.lang.String stateKey, java.lang.Class<E> clazz, Listener<E> listener)
Adds a newListener
to the store.<E> Subscription
addListener(java.lang.String stateKey, Filter<E> filter, Listener<E> listener)
Adds a newListener
to the store.<E> Subscription
addListener(java.lang.String stateKey, Listener<E> listener)
Adds a newListener
to the store.void
removeListener(Listener<?> listener)
Remove a listener from the store.void
reset(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 newListener
to the store.The provided
Listener
will be notified on any state changes. If nothing else providedFilters.DEFAULT
will 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 newListener
to the store.The provided
Listener
will be notified on any state changes. The providedFilter
is 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 newListener
to the store.The provided
Listener
will be notified on any state changes. If the provided typeE
doesn't match the object behind the passed inkey
the listener will never be notified and a warning will be logged.
If nothing else providedFilters.DEFAULT
will 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 convertingState
to 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 newListener
to the store.The provided
Listener
will be notified on any state changes. If the provided typeE
doesn't match the object behind the passed inkey
the listener will never be notified and a warning will be logged.
If nothing else providedFilters.DEFAULT
will 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 convertingState
to 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 newListener
to the store.The provided
Listener
will be notified on any changes to the part state that's tied to the passed in key. If the provided typeE
doesn't match the object behind the passed inkey
the listener will never be notified and a warning will be logged.
If nothing else providedFilters.DEFAULT
will 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 newListener
to the store.The provided
Listener
will be notified on any changes to the part state that's tied to the passed in key. If the provided typeE
doesn't match the object behind the passed inkey
the listener will never be notified and a warning will be logged.
The providedFilter
is 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 newListener
to the store.The provided
Listener
will be notified on any changes to the part state that's tied to the passed inClass
. If the provided typeE
doesn't match the object behind the passed inclass
the listener will never be notified and a warning will be logged.
If nothing else providedFilters.DEFAULT
will 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 newListener
to the store.The provided
Listener
will be notified on any changes to the part state that's tied to the passed inClass
. If the provided typeE
doesn't match the object behind the passed inclass
the listener will never be notified and a warning will be logged.
The providedFilter
is 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 newListener
to the store.The provided
Listener
will be notified on any changes to the part state that's tied to the passed inkey
and of typeclazz
. If the provided typeE
doesn't match the object behind the passed inkey
the listener will never be notified and a warning will be logged.
If nothing else providedFilters.DEFAULT
will 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 newListener
to the store.The provided
Listener
will be notified on any changes to the part state that's tied to the passed inkey
and of typeclazz
. If the provided typeE
doesn't match the object behind the passed inkey
the listener will never be notified and a warning will be logged.
The providedFilter
is 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 newListener
to 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
-
-