Skip to content

Commit 5b85cd0

Browse files
mega-blharryyan1238
authored andcommitted
AP-2214: Add back the deinit method so the task can be cancelled
1 parent 499156c commit 5b85cd0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Modules/Presentation/Features/Accounts/Sources/Accounts/Ads/ViewModel/AdsSlotViewModel.swift

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ final public class AdsSlotViewModel: ObservableObject {
2929
self.appEnvironmentUseCase = appEnvironmentUseCase
3030
}
3131

32+
deinit {
33+
monitorAdsSlotChangesTask?.cancel()
34+
monitorAdsSlotChangesTask = nil
35+
}
36+
3237
// MARK: Setup
3338
func setupSubscriptions() {
3439
NotificationCenter.default
@@ -59,6 +64,7 @@ final public class AdsSlotViewModel: ObservableObject {
5964

6065
// MARK: Ads Slot changes
6166
func monitorAdsSlotChanges() {
67+
monitorAdsSlotChangesTask?.cancel()
6268
monitorAdsSlotChangesTask = Task { [weak self, adsSlotChangeStream] in
6369
for await newAdsSlotConfig in adsSlotChangeStream.adsSlotStream {
6470
await self?.updateAdsSlot(newAdsSlotConfig)

0 commit comments

Comments
 (0)