public Reactor<Action,Mutation,State>
A Reactor is an UI-independent layer which manages the state of a view. The foremost role of a reactor is to separate control flow from a view. Every view has its corresponding reactor and delegates all logic to its reactor. A reactor has no dependency to a view, so it can be easily tested.
Reference: https://github.com/ReactorKit/ReactorKit
| Modifier and Type | Interface and Description |
|---|---|
static class |
Reactor.DefaultImpls
A Reactor is an UI-independent layer which manages the state of a view. The foremost role of a
reactor is to separate control flow from a view. Every view has its corresponding reactor and
delegates all logic to its reactor. A reactor has no dependency to a view, so it can be easily
tested.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears the state stream disposable.
|
io.reactivex.Observable<? extends State> |
createStateStream()
Creates the State stream by transforming the action relay to a state observable.
|
com.jakewharton.rxrelay2.PublishRelay<Action> |
getAction()
The action from the view. Bind user inputs to this subject.
|
State |
getCurrentState()
The current state. This value is changed just after the state stream emits a new state.
|
io.reactivex.disposables.CompositeDisposable |
getDisposables()
The CompositeDisposable that contains the State Stream disposable.
|
State |
getInitialState()
The initial state.
|
io.reactivex.Observable<? extends State> |
getState()
The state stream. Use this observable to observe the state changes.
|
io.reactivex.Observable<? extends Mutation> |
mutate(Action action)
Commits mutation from the action. This is the best place to perform side-effects such as
async tasks.
|
State |
reduce(State state,
Mutation mutation)
Generates a new state with the previous state and the action. It should be purely functional
so it should not perform any side-effects here. This method is called every time when
the mutation is committed.
|
void |
setCurrentState(State p)
The current state. This value is changed just after the state stream emits a new state.
|
io.reactivex.Observable<? extends Action> |
transformAction(io.reactivex.Observable<Action> action)
Transforms the action. Use this function to combine with other observables. This method is
called once before the state stream is created.
|
io.reactivex.Observable<? extends Mutation> |
transformMutation(io.reactivex.Observable<Mutation> mutation)
Transforms the mutation stream. Implement this method to transform or combine with other
observables. This method is called once before the state stream is created.
|
io.reactivex.Observable<State> |
transformState(io.reactivex.Observable<State> state)
Transforms the state stream. Use this function to perform side-effects such as logging. This
method is called once after the state stream is created.
|
io.reactivex.disposables.CompositeDisposable getDisposables()
The CompositeDisposable that contains the State Stream disposable.
com.jakewharton.rxrelay2.PublishRelay<Action> getAction()
The action from the view. Bind user inputs to this subject.
io.reactivex.Observable<? extends State> getState()
The state stream. Use this observable to observe the state changes.
State getInitialState()
The initial state.
State getCurrentState()
The current state. This value is changed just after the state stream emits a new state.
void setCurrentState(State p)
The current state. This value is changed just after the state stream emits a new state.
io.reactivex.Observable<? extends Mutation> mutate(Action action)
Commits mutation from the action. This is the best place to perform side-effects such as async tasks.
State reduce(State state,
Mutation mutation)
Generates a new state with the previous state and the action. It should be purely functional so it should not perform any side-effects here. This method is called every time when the mutation is committed.
io.reactivex.Observable<? extends Action> transformAction(io.reactivex.Observable<Action> action)
Transforms the action. Use this function to combine with other observables. This method is called once before the state stream is created.
io.reactivex.Observable<? extends Mutation> transformMutation(io.reactivex.Observable<Mutation> mutation)
Transforms the mutation stream. Implement this method to transform or combine with other observables. This method is called once before the state stream is created.
io.reactivex.Observable<State> transformState(io.reactivex.Observable<State> state)
Transforms the state stream. Use this function to perform side-effects such as logging. This method is called once after the state stream is created.
io.reactivex.Observable<? extends State> createStateStream()
Creates the State stream by transforming the action relay to a state observable.
void clear()
Clears the state stream disposable.