Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#if canImport(Darwin)

import SwiftUI
import Combine
import Observation

/// As of iOS 18 and aligned releases, this is no longer recommended as
/// there are cleaner alternatives like `InfiniteVerticalScrollView`
@MainActor
open class InfiniteScrollingDataSource<ListItem: Identifiable & Sendable>: ObservableObject {
@Observable
open class InfiniteScrollingDataSource<ListItem: Identifiable & Sendable> {

@Published public private(set) var items = [ListItem]()
@Published public private(set) var state: State
@Published public var paginationError: Error?
public private(set) var items = [ListItem]()
public private(set) var state: State
public var paginationError: Error?
@ObservationIgnored
private var itemFetcher: ItemFetcher

public enum State: Equatable {
Expand Down Expand Up @@ -106,5 +107,3 @@ open class InfiniteScrollingDataSource<ListItem: Identifiable & Sendable>: Obser
}
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct InfiniteDataSource_Previews: PreviewProvider {

struct ItemListView: View {

@StateObject var dataSource: ItemInfiniteDataSource
var dataSource: ItemInfiniteDataSource

var body: some View {
List {
Expand All @@ -67,7 +67,7 @@ struct InfiniteDataSource_Previews: PreviewProvider {

struct FooterView: View {

@ObservedObject var dataSource: ItemInfiniteDataSource
var dataSource: ItemInfiniteDataSource

var body: some View {
HStack(spacing: 8) {
Expand Down