Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AsyncRedux

A lightweight, async-first Redux implementation for Swift using modern concurrency features.

Features

  • Built with Swift's @Observable macro for seamless SwiftUI integration
  • Full support for async/await effects
  • Continuation-based effects for long-running operations (timers, streams)
  • Effect cancellation support
  • Type-safe state management

Installation

Swift Package Manager

Add the following to your Package.swift:

dependencies: [
    .package(url: "https://github.com/suvov/AsyncRedux.git", from: "0.0.4")
]

Or add it through Xcode: File → Add Package Dependencies → paste the repository URL.

Usage

Define your state and actions

struct AppState {
    var count: Int = 0
}

enum AppAction: Sendable {
    case increment
    case decrement
}

struct AppEnvironment {}

Create a reducer

struct AppReducer: IReducer {
    func reduceState(
        _ state: inout AppState,
        with action: AppAction,
        environment: AppEnvironment
    ) -> Effect<AppAction>? {
        switch action {
        case .increment:
            state.count += 1
        case .decrement:
            state.count -= 1
        }
        return nil
    }
}

Initialize and use the store

let store = Store(
    state: AppState(),
    reducer: AppReducer(),
    environment: AppEnvironment()
)

store.send(.increment)

Examples

See the Examples/ directory for complete examples including:

  • CounterExample - Basic counter with increment/decrement
  • DelayExample - Async actions with delays
  • FetchExample - Network requests with async effects
  • SequenceExample - Sequential effect composition
  • TimerExample - Continuation-based timer effects

Requirements

  • iOS 17.0+
  • Swift 5.9+

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages