๐ŸŸฃ Verge is a very tunable state-management engine on iOS App (UIKit / SwiftUI) and built-in ORM.

What's New



What's Changed from the last stable release

New Contributors

Full Changelog: 10.1.1...11.0.0-beta-5



๐Ÿ“An effective state management architecture for iOS - UIKit, SwiftUI๐Ÿ“
_ An easier way to get unidirectional data flow _
_ Supports concurrent processing _

swift5.5 Tests

Support this projects



  • Swift 5.7 +
  • @available(iOS 13, macOS 10.13, tvOS 10, watchOS 3)
  • UIKit
  • SwiftUI


Verge might be updated without migration guide as we are not sure how many projects are using this library. Please feel free to ask us about how to use and how to migrate.

Verge is not Flux, it's store-pattern and super powerful.

Verge is a performant store-pattern based state management library for iOS.

And the article about store-pattern

What store-pattern is

The word 'store-pattern' is used on Vue.js documentation that about how we manage the state between multiple components.

Projects which use Verge

We're welcome to publish here your application which powered by Verge!
Please Submit from Pull requests

Minimal usage example - In UIView - UIViewController

State-management is everywhere, you can put a store and start state-management.

final class CropViewController: UIViewController {

  private struct State: Equatable {
    var isSelectingAspectRatio = false
  private let store: Store<State, Never> = .init(initialState: .init())

  override public func viewDidLoad() {
    store.sinkState { [weak self] state in 
      guard let self = self else { return }
      state.ifChanged(\.isSelectingAspectRatio) { value in 


  func showAspectRatioSelection() {
    store.commit {
      $0.isSelectingAspectRatio = true
  func hideAspectRatioSelection() {
    store.commit {
      $0.isSelectingAspectRatio = false

Advanced usage exmaple - UIKit / SwiftUI

Creating a view-model (meaning Store)

final class MyViewModel: StoreComponentType {

  /// ๐Ÿ’ก The state declaration can be aslo inner-type.
  /// As possible adding Equatable for better performance.
  struct State: Equatable {
    struct NestedState: Equatable {
    var name: String = ""
    var count: Int = 0
    var nested: NestedState = .init()  

  /// ๐Ÿ’ก This is basically a template statement. You might have something type of `Store`.
  let store: Store<State, Never> = .init(initialState: .init())

  // MARK: - โœ… These are actions as well as writing methods.

  func myAction() {
    // ๐Ÿ’ฅ Mutating a state
    commit {
      $ = "Hello, Verge"

  func incrementAsync() {
    ๐Ÿ’ฅ Asynchronously mutating.
    Verge just provides thread-safety.
    We should manage operations in the Action.
    */ {    
      commit {
        // We must finish here synchronously - here is a critical session.
        $0.count += 1

In SwiftUI

Use StoreReader to read a state of the store.
It optimizes frequency of update its content for performance wise. The content closure runs when reading properties have changed or parent tree updated.

struct MyView: View {

  let store: MyViewModel

  var body: some View {
    // โœ… Uses `StateReader` to read the state this clarifies where components need the state.
    StoreReader(store) { state in
      Button(action: {
      }) {

In UIKit

Binding with a view (or view controller)

final class MyViewController: UIViewController {

  let viewModel: MyViewModel


  var cancellable: VergeAnyCancellable?

  init(viewModel: MyViewModel) {

    self.viewModel = viewModel

    // โœ… Start subscribing the state.
    self.cancellable = viewModel.sinkState { [weak self] (state: Changes<MyViewModel.State>) in
      self?.update(state: state)


  Actually we don't need to create such as this method, but here is for better clarity in this document.  
  private func update(state: Changes<MyViewModel.State>) {
    ๐Ÿ’ก `Changes` is a reference-type, but it's immutable.
    And so can not subscribe.
    Why is it a reference-type? Because it's for reducing copying cost.
    It can detect difference with previous value with it contains a previous value.
    Which is using `.ifChanged` or `.takeIfChanged`.

    /// ๐Ÿฅค An example that setting the value if the target value has updated.
    state.ifChanged(\.name) { (name) in
      // โœ… `name` has changed! Update the text.
      nameLabel.text = name
    /// ๐Ÿฅค An example that composing as a tuple to behave like RxSwift's combine latest.
    state.ifChanged({ ($, $0.count) }, ==) { (name, count) in
      Receives every time the tuple differs from the previous one.
      This means it changes when anyone in the tuple changed
      nameLabel.text = name
      countLabel.text = age.description



The details are here!

Supports Integrating with RxSwift

Verge supports to integrate with RxSwift that enables to create a stream of State and Activity. To activate it, install VergeRx module.

What differences between Flux library are

'store-pattern' is the core-concept of Flux. Flux works with the multiple restricted rules top of the 'store-pattern'.


This means we can start using like Flux without using Action, Mutation payload values.

// โœŒ๏ธ no needs to use.
enum Action {
  case increment
  case decrement

This declarations might be quite big cost of implementation in order to start to use Flux.
Verge does not have this rules, so we can do like this when we update the state.

// ๐Ÿคž just like this
extension MyStore {
  func increment() {
    commit { 
      $0.count += 1

let store: MyStore

It can be easy start.
Of course, we can create the layer to manage strict action and mutation payload on top of the Verge primitive layer.
Because 'store-pattern' is core-concept of Flux.



Verge focuses use-cases in the real-world

Recently, we could say the unidirectional data flow is a popular architecture such as flux.

Does store-pattern(flux) architecture have a good performance?

It depends. The performance will be the worst depends on how it is used.

However, most of the cases, we don't know the app we're creating how it will grow and scales.
While the application is scaling up, the performance might decrease by getting complexity.
To keep performance, we need to tune it up with several approaches.
Considering the performance takes time from the beginning.
it will make us be annoying to use flux architecture.

Verge is designed for use from small and supports to scale.

Setting Verge up quickly, and tune-up when we need it.

Verge automatically tune-up and shows us what makes performance badly while development from Xcode's documentation.

For example, Verge provides these stuff to tune performance up.

Supports volatile events

We use an event as Activity that won't be stored in the state.
This concept would help us to describe something that is not easy to describe as a state in the client application.



Verge supports also SwiftPM.


Please feel free to ask something about this library!
I can reply to you faster in Twitter.

Twitterใ‹ใ‚‰ใ ใจๆ—ฉใๅ›ž็ญ”ใงใใพใ™โ›ฑ


Demo applications

This repo has several demo applications in Demo directory. And we're looking for your demo applications to list it here! Please tell us from Issue!



๐Ÿ‡ฏ๐Ÿ‡ต Muukii (Hiroshi Kimura)


Verge is released under the MIT license.


  • Swift Tools 5.6.0
View More Packages from this Author


Last updated: Fri Mar 24 2023 19:42:53 GMT-0500 (GMT-05:00)