CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✓ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Dec 2015 |
| SPMSupports SPM | ✗ |
Maintained by Karl Bowden.
| Depends on: | |
| ReduxKit | ~> 0.1 |
| RxSwift | ~> 2.0.0-beta |
RxSwift bindings for ReduxKit.
import ReduxKitRxSwift
let store = createStore(reducer)import RxSwift
import Redux
import ReduxKitRxSwift
// Setup State, Actions and Reducers
struct State {
let count: Int
}
struct IncrementAction: SimpleStandardAction {
let meta: Any? = nil
let error: Bool = false
let rawPayload: Any? = nil
}
func reducer(previousState: State? = nil, action: Action) -> State {
let state = previousState ?? State(count: 0)
switch action {
case let action as IncrementAction:
return State(count: state.count + 1)
default:
return state
}
}
// Create the Store
let store: Store<State> = ReduxKitRxSwift.createStore(reducer)
let disposable = store.subscribe { print("Count: \($0.count)") }
// -> Count: 0
store.dispatch(IncrementAction())
// -> Count: 1
disposable.dispose()
store.dispatch(IncrementAction())
// ->func createStore<State>(reducer: Reducer, state: State? = nil)
-> Store<State>Uses createStateStream to create a ReduxKit.Store<State> using an RxSwift.Variable<State> stream.
public func createStream<State>(state: State)
-> StateStream<State>Accepts a State and returns ReduxKit.StateStream<State> using an RxSwift.Variable<State> as the stream provider.
func createDisposable(disposable: RxSwift.Disposable)
-> ReduxDisposableAccepts an RxSwift.Disposable and returns it wrapped as a ReduxDisposable.
The returned disposable only supports the disposable.dispose() function and does not return disposed state (disposable.disposed always returns false).