Skip to content

Fast and simple multi-store Redux-like architecture framework for iOS/OSX applications

License

Notifications You must be signed in to change notification settings

cooler333/Highway

Repository files navigation

Highway - create more product value in less time

Highway is an Redux-like architecture pattern implementation with Swift.

Highway

Table of contents

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

Tests

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.)
preview_low.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

General

  1. UI generate Action
  2. Action goes to Store
  3. Store mutate State (if needed)
  4. new State goes to UI
  5. Action goes to Middleware
  6. Middleware generate new action (if needed)
  7. new Action from Middleware goes to Store
  8. Store mutate State (if needed)
  9. new State goes to UI

Single shared state

Child

  • Multiple Stores share single State
  • State not copied for each new SubStore
  • State mutation goes down to parent store

Alternatives

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, [email protected]

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:

License

Highway is available under the MIT license. See the LICENSE file for more info.