Skip to content

Commit 8a9e45a

Browse files
author
Hoang Pham
committed
chore: clean up
1 parent bc03037 commit 8a9e45a

4 files changed

Lines changed: 0 additions & 74 deletions

File tree

Sources/SwiftUIQuery/InfiniteQuery.swift

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ public final class InfiniteQuery<
120120
/// Current fetch task (if any)
121121
@PerceptionIgnored private nonisolated(unsafe) var fetchTask: Task<InfiniteData<TData, TPageParam>, Error>?
122122

123-
/// Whether the query has been destroyed
124-
private var isDestroyed = false
125-
126123
/// Timestamp when query became inactive (no active observers)
127124
private var inactiveAt: Date?
128125

@@ -460,18 +457,6 @@ public final class InfiniteQuery<
460457
}
461458
}
462459

463-
/// Destroy the query and clean up resources
464-
public func destroy() {
465-
guard !isDestroyed else { return }
466-
isDestroyed = true
467-
468-
cancel()
469-
cleanup()
470-
471-
// Remove from cache
472-
cache?.remove(self)
473-
}
474-
475460
// MARK: - Pagination Operations
476461

477462
/// Get the next page parameter from current data
@@ -893,15 +878,6 @@ public final class InfiniteQuery<
893878
// Remove from cache (let cache handle the cleanup)
894879
cache?.remove(self)
895880
}
896-
897-
/// Clean up resources
898-
private func cleanup() {
899-
fetchTask?.cancel()
900-
fetchTask = nil
901-
observers.removeAll()
902-
inactiveAt = nil
903-
currentFetchDirection = nil
904-
}
905881
}
906882

907883
// MARK: - AnyInfiniteQuery Protocol Implementation

Sources/SwiftUIQuery/InfiniteQueryObserver.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,6 @@ public final class InfiniteQueryObserver<
207207
/// Timer for stale timeout
208208
@PerceptionIgnored private nonisolated(unsafe) var staleTimer: Timer?
209209

210-
/// Timer for refetch interval
211-
@PerceptionIgnored private nonisolated(unsafe) var refetchTimer: Timer?
212-
213210
// MARK: - Initialization
214211

215212
public init(client: QueryClient, options: InfiniteQueryOptions<TData, QueryError, TKey, TPageParam>) {
@@ -231,7 +228,6 @@ public final class InfiniteQueryObserver<
231228
deinit {
232229
// Clean up timers synchronously
233230
staleTimer?.invalidate()
234-
refetchTimer?.invalidate()
235231
}
236232

237233
// MARK: - Public Methods
@@ -339,13 +335,6 @@ public final class InfiniteQueryObserver<
339335
clearTimers()
340336
}
341337

342-
/// Destroy the observer and clean up all resources
343-
public func destroy() {
344-
unsubscribe()
345-
clearTimers()
346-
currentQuery = nil
347-
}
348-
349338
// MARK: - AnyQueryObserver Protocol
350339

351340
public func getCurrentResult() -> AnyQueryResult {
@@ -537,8 +526,6 @@ public final class InfiniteQueryObserver<
537526
private func clearTimers() {
538527
staleTimer?.invalidate()
539528
staleTimer = nil
540-
refetchTimer?.invalidate()
541-
refetchTimer = nil
542529
}
543530
}
544531

Sources/SwiftUIQuery/Query.swift

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ public final class Query<TData: Sendable, TKey: QueryKey>: AnyQuery {
118118
/// Current fetch task (if any)
119119
@PerceptionIgnored private nonisolated(unsafe) var fetchTask: Task<TData, Error>?
120120

121-
/// Whether the query has been destroyed
122-
private var isDestroyed = false
123-
124121
/// Timestamp when query became inactive (no active observers)
125122
private var inactiveAt: Date?
126123

@@ -435,18 +432,6 @@ public final class Query<TData: Sendable, TKey: QueryKey>: AnyQuery {
435432
}
436433
}
437434

438-
/// Destroy the query and clean up resources
439-
public func destroy() {
440-
guard !isDestroyed else { return }
441-
isDestroyed = true
442-
443-
cancel()
444-
cleanup()
445-
446-
// Remove from cache
447-
cache?.remove(self)
448-
}
449-
450435
// MARK: - Observer Management
451436

452437
/// Add an observer to this query
@@ -737,14 +722,6 @@ public final class Query<TData: Sendable, TKey: QueryKey>: AnyQuery {
737722
// Remove from cache (let cache handle the cleanup)
738723
cache?.remove(self)
739724
}
740-
741-
/// Clean up resources
742-
private func cleanup() {
743-
fetchTask?.cancel()
744-
fetchTask = nil
745-
observers.removeAll()
746-
inactiveAt = nil
747-
}
748725
}
749726

750727
// MARK: - QueryState Extensions

Sources/SwiftUIQuery/QueryObserver.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,6 @@ public final class QueryObserver<TData: Sendable, TKey: QueryKey>: AnyQueryObser
143143
/// Timer for stale timeout
144144
@PerceptionIgnored private nonisolated(unsafe) var staleTimer: Timer?
145145

146-
/// Timer for refetch interval
147-
@PerceptionIgnored private nonisolated(unsafe) var refetchTimer: Timer?
148-
149146
// MARK: - Initialization
150147

151148
public init(client: QueryClient, options: QueryOptions<TData, TKey>) {
@@ -164,7 +161,6 @@ public final class QueryObserver<TData: Sendable, TKey: QueryKey>: AnyQueryObser
164161
deinit {
165162
// Clean up timers synchronously
166163
staleTimer?.invalidate()
167-
refetchTimer?.invalidate()
168164
}
169165

170166
// MARK: - Public Methods
@@ -240,13 +236,6 @@ public final class QueryObserver<TData: Sendable, TKey: QueryKey>: AnyQueryObser
240236
clearTimers()
241237
}
242238

243-
/// Destroy the observer and clean up all resources
244-
public func destroy() {
245-
unsubscribe()
246-
clearTimers()
247-
currentQuery = nil
248-
}
249-
250239
// MARK: - AnyQueryObserver Protocol
251240

252241
public func getCurrentResult() -> AnyQueryResult {
@@ -460,9 +449,6 @@ public final class QueryObserver<TData: Sendable, TKey: QueryKey>: AnyQueryObser
460449
private func clearTimers() {
461450
staleTimer?.invalidate()
462451
staleTimer = nil
463-
464-
refetchTimer?.invalidate()
465-
refetchTimer = nil
466452
}
467453
}
468454

0 commit comments

Comments
 (0)