Swiftpack.co - Package - clmntcrl/swidux-watchmen

🙂 SwiduxWatchmen

Swidux middleware for action side effects using "Watchmen".

Stability

This library should be considered alpha, and not stable. Breaking changes will happen often.

Usage

Create a Watchmen that could react to some actions to handle side effects and then dispatch other actions.

let doomsdayClockWatchmen = Watchmen { action in
    switch action {
    case DoomsdayClockAction.fetchDoomsdayClock:
        fetchDoomsdayClock {
            store.dispatch(DoomsdayClockAction.fetchDoomsdayClockSuccess(clock: $0))
        }
    default: break
    }
}

Add your watchmen to your Store middlewares.

import Swidux
import SwiduxWatchmen

let store = Store<AppState>(
    initialState: AppState(),
    reducer: reducer,
    middlewares: [
        .create(combiningWatchmen: [ doomsdayClockWatchmen ]),
    ]
)

Installation

Carthage

Add the following dependency to your Cartfile:

github "clmntcrl/swidux" ~> 0.1.1
github "clmntcrl/swidux-watchmen" ~> 0.1.1
$ carthage update

You should encounter an issue (something like Dependency "swidux-watchmen" has no shared framework schemes) because libraries using SwiftPM are not currently supported by Carthage. This can be resolved with the following:

$ (cd Carthage/Checkouts/swidux-watchmen && swift package generate-xcodeproj)
$ carthage build swidux-watchmen

SwiftPM

Add package as dependency:

import PackageDescription

let package = Package(
    dependencies: [
        .package(url: "https://github.com/clmntcrl/swidux.git", from: "0.1.1"),
        .package(url: "https://github.com/clmntcrl/swidux-watchmen.git", from: "0.1.1"),
    ]
)
$ swift build

License

SwiduxWatchmen is released under the MIT license. See LICENSE for details.

Github

link
Stars: 0
Help us keep the lights on

Dependencies

Used By

Total: 0

Releases

0.1.1 - Nov 5, 2018

0.1.0 - Oct 30, 2018