text: ReSwiftReSwift
  Supported Swift Versions: Swift 4.2, 5.x
  For Swift 3.2 or 4.0 Support use Release 5.0.0 or earlier. For Swift 2.2 Support use Release 2.0.0 or earlier.
  IntroductionIntroduction...
  - Views: in a ReSwift app your views update when your state changes. Your views become simple visualizations of the current app state.
  - State Changes: in a ReSwift app you can only perform state changes through actions. Actions are small pieces of data that describe a state change. By drastically limiting the way state can be mutated, your app becomes easier to understand and it gets easier to work with many collaborators.
  The ReSwift library is tiny - allowing users to dive into the code, understand every single line and hopefully contribute.
  ReSwift is quickly growing beyond the core library, providing experimental extensions for routing and time traveling through past app states!
  Excited? So are we
  Table of ContentsTable of Contents
  - About ReSwift
  - Why ReSwift?
  - Getting Started Guide
  - Installation
  - Checking Out Source Code
  - Demo
  - Extensions
  - Example Projects
  - Contributing
  - Credits
  - Get in touch
  About ReSwiftAbout ReSwift
  ReS, that maintains a counter that can be increased and decreased, you can define the app state as following:
  struct AppState { var counter: Int = 0 }
  You would also define two actions, one for increasing and one for decreasing the counter. In the Getting Started Guide you can find out how to construct complex actions. For the simple actions in this example we can define empty structs that conform to action:
  struct CounterActionIncrease: Action {} struct CounterActionDecrease: Action {}
  Your reducer needs to respond to these different action types, that can be done by switching over the type of action:
  func counterReducer(action: Action, state: AppState?) -> AppState { var state = state ?? AppState() switch action { case _ as CounterActionIncrease: state.counter += 1 case _ as CounterActionDecrease: state.counter -= 1 default: break } return state }, StoreSubscriber { @IBOutlet var counterLabel: UILabel! override func viewWillAppear(_ animated: Bool) { mainStore.subscribe(self) } override func viewWillDisappear(_ animated: Bool) { mainStore.unsubscribe(self) } func newState(state: AppState) { counterLabel.text = "\(state.counter)" } @IBAction func increaseButtonTapped(_ sender: UIButton) { mainStore.dispatch( CounterActionIncrease() ) } @IBAction func decreaseButtonTapped(_ sender: UIButton) { mainStore.dispatch( CounterActionDecrease() ) } }
  The
  newState method will be called by the
  Store ReSwift's features, read the Getting Started Guide to see how you can build entire apps with this architecture. For a complete implementation of this example see the CounterExample project.
  Create a subscription of several substates combinedCreate a subscription of several substates combined
  Just create a struct representing the data model needed in the subscriber class, with a constructor that takes the whole app state as a param. Consider this constructor as a mapper/selector from the app state to the subscriber state. Being
  MySubState a struct and conforming to
  Equatable, ReSwift (by default) will not notify the subscriber if the computed output hasn't changed. Also, Swift will be able to infer the type of the subscription.
  struct MySubState: Equatable { // Combined substate derived from the app state. init(state: AppState) { // Compute here the substate needed. } }
  store.subscribe(self) { $0.select(MySubState.init) } func newState(state: MySubState) { // Profit! }
  Why ReSwift?Why ReS.
  ReSwift attempts to solve these problem by placing strong constraints on the way applications can be written. This reduces the room for programmer error and leads to applications that can be easily understood - by inspecting the application state data structure, the actions and the reducers.
  This architecture provides further benefits beyond improving your code base:
  - Stores, Reducers, Actions and extensions such as ReSwift Router are entirely platform independent - you can easily use the same business logic and share it between apps for multiple platforms (iOS, tvOS, etc.)
  - Want to collaborate with a co-worker on fixing an app crash? Use ReSwift Recorder to record the actions that lead up to the crash and send them the JSON file so that they can replay the actions and reproduce the issue right away.
  - Maybe recorded actions can be used to build UI and integration tests?
  The ReSwift tooling is still in a very early stage, but aforementioned prospects excite me and hopefully others in the community as well!
  You can also watch this talk on the motivation behind ReSwift.
  Getting Started GuideGetting Started Guide
  A Getting Started Guide that describes the core components of apps built with ReSwift lives here.
  To get an understanding of the core principles we recommend reading the brilliant redux documentation.
  InstallationInstallation
  CocoaPodsCocoaPods
  You can install ReSwift via CocoaPods by adding it to your
  Podfile:
  use_frameworks! source '' platform :ios, '8.0' pod 'ReSwift'
  And run
  pod install.
  CarthageCarthage
  You can install ReSwift via Carthage by adding the following line to your
  Cartfile:
  github "ReSwift/ReSwift"
  AccioAccio
  You can install ReSwift via Accio by adding the following line to your
  Package.swift:
  .package(url: "", .upToNextMajor(from: "5.0.0")),
  Next, add
  ReSwift to your App targets dependencies like so:
  .target( name: "App", dependencies: [ "ReSwift", ] ),
  Then run
  accio update.
  Swift Package ManagerSwift Package Manager
  You can install ReSwift via Swift Package Manager by adding the following line to your
  Package.swift:
  import PackageDescription let package = Package( [...] dependencies: [ .package(url: "", from: "5.0.0"), ] )
  Checking out Source CodeChecking out Source Code
  After checking out the project run
  pod install to get the latest supported version of SwiftLint, which we use to ensure a consistent style in the codebase.
  DemoDemo
  Using this library you can implement apps that have an explicit, reproducible state, allowing you, among many other things, to replay and rewind the app state, as shown below:
  ExtensionsExtensions
  This repository contains the core component for ReSwift, the following extensions are available:
  - ReSwift-Thunk: Provides a ReSwift middleware that lets you dispatch thunks (action creators) to encapsulate processes like API callbacks.
  - ReSwift-Router: Provides a ReSwift compatible Router that allows declarative routing in iOS applications
  - ReSwift-Recorder: Provides a
  Storeimplementation that records all
  Actions and allows for hot-reloading and time travel
  Example ProjectsExample Projects
  - CounterExample: A very simple counter app implemented with ReSwift.
  - CodeProduction Apps with Open Source Code
  - Persephone, a MPD music player daemon controller for macOS
  - Product Hunt for OS X Official Product Hunt client for macOS
  ContributingContributing
  There's still a lot of work to do here! We would love to see you involved! You can find all the details on how to get started in the Contributing Guide.
  CreditsCredits
  - Thanks a lot to Dan Abramov for building Redux - all ideas in here and many implementation details were provided by his library.
  Get in touchGet in touch
  If you have any questions, you can find the core team on twitter:
  We also have a public gitter chat!