You can also check the demo app implementations from VergeStoreDemoUIKit.

<aside> ⚠️ This article is under work in progress.

</aside>

Differs with SwiftUI, the developers have to update the UI with updates partially according to state updates.

In a screen that does not have dynamic item contents, it won’t be so much hard.

However, we should consider the strategy of how we update the cells when we use the dynamic list such as UICollectionView or UITableView.

This article shows you how we get to do this as a one of the strategies.

Using multiple stores to connect with a particular UI

We have only one store that has the source of truth. This won’t change. Additionally, we could create another store that states will be derived from the source of truth.

In the below figure, Store, ViewModel, and CellModel are Store.

https://user-images.githubusercontent.com/1888355/88272709-18f57180-cd14-11ea-8828-bf189f8cfbf2.png

Let’s take a look simple example with this one entity.

struct Post {
  var id: String
  var body: String
  var createdAt: Date
  var author: String
}

We dispaly a cell that displays Post entity in UICollectionView.

To be done, we will have following types.

struct RootState: Equatable {
  var posts: [String : Post] = [:]
}

final class RootStore: Store<RootState, Never> {

}