Skip to content

Commit 10e5506

Browse files
authored
Improve UIKit case studies: ListsOfState (#3220)
1 parent b60b129 commit 10e5506

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Examples/CaseStudies/UIKitCaseStudies/ListsOfState.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ let cellIdentifier = "Cell"
2525
final class CountersTableViewController: UITableViewController {
2626
let store: StoreOf<CounterList>
2727

28+
var observations: [IndexPath: ObservationToken] = [:]
29+
2830
init(store: StoreOf<CounterList>) {
2931
self.store = store
3032
super.init(nibName: nil, bundle: nil)
@@ -51,7 +53,8 @@ final class CountersTableViewController: UITableViewController {
5153
{
5254
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath)
5355
cell.accessoryType = .disclosureIndicator
54-
observe { [weak self] in
56+
observations[indexPath]?.cancel()
57+
observations[indexPath] = observe { [weak self] in
5558
guard let self else { return }
5659
cell.textLabel?.text = "\(store.counters[indexPath.row].count)"
5760
}

0 commit comments

Comments
 (0)