Awesome
Highway - create more product value in less time
Highway is an Redux-like architecture pattern implementation with Swift.
<img src="Resources/jared-murray-NSuufgf-BME-unsplash.jpg" alt="Highway" width="400"/>Table of contents
- Features
- Tutorials (Step by step guide)
- Examples
- Requirements
- Installation (Cocoapods / SPM)
- Schemes
- Alternatives
- Tools used in project
- Author
- Credits and thanks
Features
- Child stores
- Fast state updates
- 100% business logic code coverage
- Lightweight
- Do not use 3rd party libraries
- Can be used with SwiftUI
- Support structs & classes for state (structs preferred)
- Thread safe
- Can be used with async/await
createMiddleware({ dispatch, getState, action in
switch action {
case .randomize:
Task.init {
let rand = await generateRandomValue()
dispatch(.receiveRandomValue(Int(rand)))
}
}
})
Tutorials (Step by step guide)
Examples
Integration
Swift UI
- SimpleView: SwiftUI View with updates
- ListWithAimations: Data Driven UI using SwiftUI List
Tests
- Snapshot testing: Snapshot tests based on fast unit tests
- Unit testing business logic: Custom logic tests / Integration tests for Model Layer
Light/Small Apps
- Counter: Lighweight multi store app (Single view controller with multiple child view controller)
- SocketPingPong: An app with stream of events (like web socket or server side events)
- ReusableViewControllers: Reuse view controller or view which was written with imperative style and similar example using ViewStore
- Animation: Animation inside TableView cells using DiffableDataSource & SwiftUI List views(items)
- TableViewsSync: TableView with animations (deletions/insertions) and syncronisation
Heavy Apps
- InfiniteScroll: Enterprise solution app (with Dependency Injection, Flow Coordinator e.t.c.)
https://user-images.githubusercontent.com/2772537/177874199-1ba154f8-7982-4016-8618-dc59f76a5d6f.mov
Requirements
- iOS: 13.0
- Swift: 5.4
Installation (Cocoapods / SPM)
Highway is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Highway'
Also you can integrate framework as SPM package
Schemes
Simple unidirectional data flow
<img src="Resources/arch_animation.gif" alt="General" width="600"/>- UI generate Action
- Action goes to Store
- Store mutate State (if needed)
- new State goes to UI
- Action goes to Middleware
- Middleware generate new action (if needed)
- new Action from Middleware goes to Store
- Store mutate State (if needed)
- new State goes to UI
Single shared state
<img src="Resources/ChildStoreScheme.png" alt="Child" width="400"/>- Multiple Stores share single State
- State not copied for each new SubStore
- State mutation goes down to parent store
Alternatives
- Mobius.swift
- ReSwift
- ReCombine
- Swift Composable Architecture
- Tea In Swift
- SwiftRex
- Katana
- ReactorKit
- Tempura
- RxFeedback
- More
Tools used in project
- rbenv: Manage your app's Ruby environment (quote from rbenv github web page)
- Bundler: The best way to manage a Ruby application's gems (quote from Bundler web page)
- Git LFS: An open source Git extension for versioning large files (quote from git-lfs web page)
TODO
- Add pros and cons to alternatives
- Add area of responsibility for Highway types
Author
Dmitrii Cooler, coolerov333@gmail.com
Credits and thanks
The following people gave feedback on the library at its early stages and helped make the library what it is today:
Special thanks to:
- Aleksey Alekseev who helped me to improve library performance
- Dmitii Bobrov with major feedback on early concepts
License
Highway is available under the MIT license. See the LICENSE file for more info.