diff --git a/Examples/CaseStudies/UIKitCaseStudies/ListsOfState.swift b/Examples/CaseStudies/UIKitCaseStudies/ListsOfState.swift index 608db316e88f..ba9367b58530 100644 --- a/Examples/CaseStudies/UIKitCaseStudies/ListsOfState.swift +++ b/Examples/CaseStudies/UIKitCaseStudies/ListsOfState.swift @@ -25,6 +25,8 @@ let cellIdentifier = "Cell" final class CountersTableViewController: UITableViewController { let store: StoreOf + var observations: [IndexPath: ObservationToken] = [:] + init(store: StoreOf) { self.store = store super.init(nibName: nil, bundle: nil) @@ -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)" }