mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
878 B
Swift
28 lines
878 B
Swift
// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
import GRDB
|
|
import SessionUtilitiesKit
|
|
|
|
protocol PagedObservationSource {
|
|
associatedtype PagedTable: TableRecord & ColumnExpressible & Identifiable
|
|
associatedtype PagedDataModel: FetchableRecordWithRowId & Identifiable
|
|
|
|
var pagedDataObserver: PagedDatabaseObserver<PagedTable, PagedDataModel>? { get }
|
|
|
|
func didInit(using dependencies: Dependencies)
|
|
func loadPageBefore()
|
|
func loadPageAfter()
|
|
}
|
|
|
|
extension PagedObservationSource {
|
|
public func didInit(using dependencies: Dependencies) {
|
|
dependencies.storage.addObserver(pagedDataObserver)
|
|
}
|
|
}
|
|
|
|
extension PagedObservationSource where PagedTable.ID: SQLExpressible {
|
|
func loadPageBefore() { pagedDataObserver?.load(.pageBefore) }
|
|
func loadPageAfter() { pagedDataObserver?.load(.pageAfter) }
|
|
}
|