Skip to content

Commit ef14678

Browse files
authored
[Demo]Reduce the amount of statsReport kept in memory (#979)
1 parent f23837b commit ef14678

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

DemoApp/Sources/Views/StatsView/DemoStatsAdapter.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@ final class DemoStatsAdapter {
2929
callStatsReportCancellable = call?
3030
.state
3131
.$statsReport
32+
.receive(on: DispatchQueue.main)
3233
.sink { [weak self] in
33-
if let report = $0 { self?.reports.append(report) }
34+
guard let self, let report = $0 else { return }
35+
36+
reports.append(report)
37+
38+
if reports.endIndex > 20 {
39+
_ = reports.dropFirst()
40+
}
3441
}
3542
}
3643
}

0 commit comments

Comments
 (0)