FUIListViewModel
public class FUIListViewModel<Entity, Section> : ObservableObject where Entity : Hashable, Entity : Identifiable, Section : CaseIterable, Section : Hashable
The generic-typed FUIListViewModel
wrapping the data from a data query loader and providing state to the UI components.
-
The number of items in new paginated entity list.
Declaration
Swift
public private(set) var newListResultsCount: Int { get }
-
The number of items in new paginated search results list.
Declaration
Swift
public private(set) var newSearchResultsCount: Int { get }
-
A boolean indicates if the entity list to be paginated or not.
Declaration
Swift
public private(set) var isListPagingEnabled: Bool { get }
-
A boolean indicates if search results list to be paginated or not.
Declaration
Swift
public private(set) var isSearchPagingEnabled: Bool { get }
-
A boolean indicates if search mode is allowed for the view model.
Declaration
Swift
public private(set) var isSearchEnabled: Bool { get }
-
Indicates current execution
state for
FUIListViewModel`.Declaration
Swift
public private(set) var state: FUIListViewModelState { get }
-
Provides the number of list results items that are already loaded.
Declaration
Swift
public private(set) var loadedListItemsCount: Int { get }
-
Provides the number of search results items that are already loaded.
Declaration
Swift
public private(set) var loadedSearchedItemsCount: Int { get }
-
Provides the number of list results pages that are already loaded.
Declaration
Swift
public private(set) var loadedListPageCount: Int { get }
-
Provides the number of search results pages that are already loaded.
Declaration
Swift
public private(set) var loadedSearchedPageCount: Int { get }
-
Defines the number of entities to be displayed in the initial list results page.
Declaration
Swift
public var initListPageSize: Int
-
Defines the number of entities to be displayed in a new list results page.
Declaration
Swift
public var newListPageSize: Int
-
Defines the number of entities to be displayed in the initial search results page.
Declaration
Swift
public var initSearchPageSize: Int
-
Defines the number of entities to be displayed in a new search results page.
Declaration
Swift
public var newSearchPageSize: Int
-
A boolean indicates if the view model is in search query mode.
Declaration
Swift
public private(set) var isSearchActive: Bool { get }
-
Creates a list view model.
Declaration
Swift
public init(queries: [Section : FUIDataLoader<Entity>] = [:], isListPagingEnabled: Bool? = nil, isSearchPagingEnabled: Bool? = nil, isSearchEnabled: Bool? = nil)
Parameters
queries
The data query that is used to fetch data for each section.
isListPagingEnabled
Optional boolean indicates if list results to be paginated. Default to
true
.isSearchPagingEnabled
Optional boolean indicates if search results to be paginated. Default to
true
.isSearchEnabled
Optional boolean indicates if search control is allowed. Default to
false
. -
Fetches list results for a specific section.
Declaration
Swift
public func fetchListData(for section: Section)
Parameters
for
Defines the section that needs to fetch new data.
-
Refresh list results for a specific section.
Declaration
Swift
public func refreshListData(for section: Section)
Parameters
for
Defines the section that needs to refresh data.
-
Fetches search results for a specific section.
Declaration
Swift
public func fetchSearchData(for section: Section, with searchString: String)
Parameters
for
Defines the section that needs to update search results.
with
Search string that will be used in the data query.
-
Defines current state for
See moreFUIListViewModel
.Declaration
Swift
public enum FUIListViewModelState : Equatable