Swiftpack.co -  NicholasTD07/TDRedux.swift as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Yet another Redux written in Swift
.package(url: "https://github.com/NicholasTD07/TDRedux.swift.git", from: "3.0.0")


CocoaPods Carthage compatible Swift Package Manager

Travis Codecov CocoaPods License

Yet another Redux written in Swift


Swift Package Manager

Add this repo as a dependency in your Package.swift file, for example:

import PackageDescription

let package = Package(
    name: "Example",
    dependencies: [
        .Package(url: "https://github.com/NicholasTD07/TDRedux.swift.git",
                 majorVersion: 2),


github "NicholasTD07/TDRedux.swift" ~> 2.0


pod 'TDRedux.swift', '~> 2.0'



A Store holds a State. A State is the entire internal state of an application, which could be anything.

You can

  • create a Store with a Reducer
  • dispatch Actions to change a Store's State
  • subscribe to changes happens to the State of a Store

Read more: Redux in Swift Part 1 - Store and State

Reducer Type

A Reducer is a function which takes an optional State and an Action and returns a new State, defined as the following:

class Store<State> {
    typealias Reducer = (State?, Action) -> State

Read more: Redux in Swift Part 1 - Reducer and Action


An Action describes what happened while it may carry some data, e.g. AddTodo(text: "buy milk") or ToggleTodo(atIndex: 1)

Action type is defined as

typealias Action = Any

Read more: Redux in Swift Part 1 - Reducer and Action

Reducer function

A helper function which wraps Reducers that take non-optional State and specific type of Action, so that: No more type-casting in hand written Reducers anymore. For example:

typealias CounterState = Int

enum CounterActions {
  case increase
  case decrease

let counterReducer: (CounterState, CounterActions) = /* ... */
let wrappedReducer: (CounterState?, Any) = Reducer(initialState: 0, reducer: counterReducer)

let counterStore = Store<CounterState>.init(with: wrappedReducer)


A helper function which combines an array of Reducers into one. For example:

typealias State = /* ... */
let arranOfReducers: [(State?, Any)] = [ /* ... */ ]
let combinedReducers: (State?, Any) = combineReducers(arranOfReducers)


It provides a third-party extension point between dispatching an action, and the moment it reaches the reducer.

Redux doc: Middleware

What's Experimental?

Everything in Store is final

Store and every property and methods in Store are defined as final.

Let me know if you think the Store need to be subclassed and overridden.


I am not too familiar with this concept in Redux and also I am not sure whether there are potential issues in my implementation or not.


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

Read More


Stars: 1
Last commit: 3 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

Swift 5!
2 years ago
  • Rename combine(reducers:) to combined(reducers:)
  • Update to Swift 5

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API