Skip to content

Commit

Permalink
Improve UIKit case studies: ListsOfState (pointfreeco#3220)
Browse files Browse the repository at this point in the history
  • Loading branch information
takehilo authored and junbangg committed Jul 14, 2024
1 parent 476f192 commit 4eeb247
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 {
private 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 4eeb247

Please sign in to comment.