Skip to content

Commit

Permalink
Improve UIKit case studies: ListsOfState (#3220)
Browse files Browse the repository at this point in the history
  • Loading branch information
takehilo authored Jul 12, 2024
1 parent b60b129 commit 10e5506
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Examples/CaseStudies/UIKitCaseStudies/ListsOfState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ let cellIdentifier = "Cell"
final class CountersTableViewController: UITableViewController {
let store: StoreOf<CounterList>

var observations: [IndexPath: ObservationToken] = [:]

init(store: StoreOf<CounterList>) {
self.store = store
super.init(nibName: nil, bundle: nil)
Expand All @@ -51,7 +53,8 @@ final class CountersTableViewController: UITableViewController {
{
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath)
cell.accessoryType = .disclosureIndicator
observe { [weak self] in
observations[indexPath]?.cancel()
observations[indexPath] = observe { [weak self] in
guard let self else { return }
cell.textLabel?.text = "\(store.counters[indexPath.row].count)"
}
Expand Down

0 comments on commit 10e5506

Please sign in to comment.