clmntcrl / swidux-watchmen

Middleware for action side effects in Swidux using “Watchmen“ 🙂

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🙂 SwiduxWatchmen

Middleware for action side effects in Swidux using “Watchmen“ 🙂

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

Add the following dependency to your Cartfile:

github "clmntcrl/swidux-watchmen" ~> 0.2

Add the following pod to your Podfile:

pod 'SwiduxWatchmen', '~> 0.2'

Add the package as dependency in your Package.swift:

dependencies: [
    .package(url: "https://github.com/clmntcrl/swidux-watchmen.git", from: "0.2.0"),
]

License

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

About

Middleware for action side effects in Swidux using “Watchmen“ 🙂

License:MIT License


Languages

Language:Swift 68.9%Language:Ruby 18.9%Language:Makefile 12.2%