A lightweight, async-first Redux implementation for Swift using modern concurrency features.
- Built with Swift's
@Observablemacro 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
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.
struct AppState {
var count: Int = 0
}
enum AppAction: Sendable {
case increment
case decrement
}
struct AppEnvironment {}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
}
}let store = Store(
state: AppState(),
reducer: AppReducer(),
environment: AppEnvironment()
)
store.send(.increment)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
- iOS 17.0+
- Swift 5.9+
MIT License