Latest 0.1.0
Homepage https://github.com/ReduxKit/ReduxKitReactiveKit
License MIT
Platforms ios 8.0, osx 10.10
Dependencies ReduxKit, ReactiveKit
Authors ,

ReactiveKit bindings for ReduxKit.

Usage / Quick start

import ReactiveKit
import ReduxKit
import ReduxKitReactiveKit

// 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> = ReduxKitReactiveKit.createStore(reducer)

let disposable = store.subscribe { print("Count: ($0.count)") }
// -> Count: 0

store.dispatch(IncrementAction())
// -> Count: 1

disposable.dispose()

store.dispatch(IncrementAction())
// ->

Installation

Carthage

Add ReduxKitReactiveKit to Cartfile

github "ReduxKit/ReduxKitReactiveKit" ~> 0.1

Run in terminal:

$ carthage update

CocoaPods

Add ReduxKitReactiveKit to your Podfile:

pod 'ReduxKitReactiveKit', '~> 0.1'

Then, run the following command:

$ pod install

API

createStore

func createStore<State>(reducer: Reducer, state: State? = nil)
    -> Store<State>

Uses createStateStream to create a ReduxKit.Store<State> using a ReactiveKit.Observable<State> stream.

createStateStream

public func createStream<State>(state: State)
    -> StateStream<State>

Accepts a State and returns ReduxKit.StateStream<State> using a ReactiveKit.Observable<State> as the stream provider.

createDisposable

func createDisposable(disposable: ReactiveKit.Disposable)
    -> ReduxDisposable

Accepts a ReactiveKit.DisposableType and returns it wrapped as a ReduxDisposable.

Latest podspec

{
    "name": "ReduxKitReactiveKit",
    "version": "0.1.0",
    "summary": "ReactiveKit bindings for ReduxKit",
    "homepage": "https://github.com/ReduxKit/ReduxKitReactiveKit",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Aleksander Herforth Rendtslev": "[email protected]",
        "Karl Bowden": "[email protected]"
    },
    "source": {
        "git": "https://github.com/ReduxKit/ReduxKitReactiveKit.git",
        "tag": "0.1.0"
    },
    "source_files": "ReduxKitReactiveKit",
    "dependencies": {
        "ReduxKit": [
            "~> 0.1"
        ],
        "ReactiveKit": [
            "~> 1.0"
        ]
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.10"
    }
}

Pin It on Pinterest

Share This