import { BehaviorSubject, Observable, Subject } from 'rxjs'; import { VirtualizedListQueryDirection, VirtualizedListQueryState, VirtualizedListScrollPosition, VirtualizedListVerticalItemPosition } from './types'; /** * The `VirtualizedListService` removes items from a list that are not currently displayed. This is a high-level overview of how it works: * - Create a new instance for each list that needs virtualization * - Input: Provide a reactive stream that emits all items in the list * - Input: Provide a reactive stream that emit the current scroll position (top, middle or bottom) * - Input: maximum number of items that are allowed in the list (in practice the service can make the virtualized list half this number, you should take this into account when choosing the value) * - Output: The service will emit the current list of displayed items via the virtualized items reactive stream * - For simplicity, the service won't track the height of the items, nor it needs an exact scroll location -> this is how removing items work: * - If scroll location is bottom/top items around the current bottom/top item will be emitted in the virtualized items stream * - If scroll location is middle, the service won't remove items, if new items are received, those will be appended to the virtualized list (this means that in theory the list can grow very big if a lot of new items are received while the user is scrolled somewhere, this is a trade-off for the simplicity of no height tracking) * - Since there is no height tracking, you should make sure to provide a maximum number that is big enough to fill the biggest expected screen size twice * - If the user scrolls to the bottom/top and there are no more local items to show, the service will trigger a query to load more items * - Input: you should provide the page size to use, in order for the service to determine if loading is necessary * * The `VirtualizedMessageListService` provides an implementation for the message list component. */ export declare abstract class VirtualizedListService { private allItems$; private scrollPosition$; readonly jumpToItem$?: Observable<{ item: Partial | undefined; position?: VirtualizedListVerticalItemPosition | undefined; }> | undefined; readonly pageSize: number; readonly maxItemCount: number; /** * The items that should be currently displayed, a subset of all items */ virtualizedItems$: Observable; /** * The result of the last query used to load more items */ queryState$: Observable; protected queryStateSubject: BehaviorSubject; protected bufferOnTop: number; protected bufferOnBottom: number; protected loadFromBuffer$: Subject; private virtualizedItemsSubject; private subscriptions; constructor(allItems$: Observable, scrollPosition$: Observable, jumpToItem$?: Observable<{ item: Partial | undefined; position?: VirtualizedListVerticalItemPosition | undefined; }> | undefined, pageSize?: number, maxItemCount?: number); /** * The current value of virtualized items */ get virtualizedItems(): T[]; /** * Remove all subscriptions, call this once you're done using an instance of this service */ dispose(): void; protected loadMoreFromBuffer(_: VirtualizedListQueryDirection): void; private loadMore; protected abstract isEqual: (t1: T, t2: T) => boolean; protected abstract query: (direction: VirtualizedListQueryDirection) => Promise; }