import { TrackByFunction, NgIterable, ChangeDetectorRef, NgZone, ErrorHandler, ViewContainerRef, TemplateRef, EmbeddedViewRef, IterableDiffers } from '@angular/core'; import { RxStrategies, RxStrategyNames, RxStrategyProvider } from '@rx-angular/cdk/render-strategies'; import * as rxjs from 'rxjs'; import { Observable, ReplaySubject } from 'rxjs'; import { RxNotification, RxNotificationKind } from '@rx-angular/cdk/notifications'; /** * A type representing the live collection to be reconciled with any new (incoming) collection. This * is an adapter class that makes it possible to work with different internal data structures, * regardless of the actual values of the incoming collection. */ declare abstract class LiveCollection { abstract get length(): number; abstract at(index: number): V; abstract attach(index: number, item: T): void; abstract detach(index: number): T; abstract create(index: number, value: V): T; destroy(item: T): void; updateValue(index: number, value: V): void; swap(index1: number, index2: number): void; move(prevIndex: number, newIdx: number): void; } /** * The live collection reconciliation algorithm that perform various in-place operations, so it * reflects the content of the new (incoming) collection. * * The reconciliation algorithm has 2 code paths: * - "fast" path that don't require any memory allocation; * - "slow" path that requires additional memory allocation for intermediate data structures used to * collect additional information about the live collection. * It might happen that the algorithm switches between the two modes in question in a single * reconciliation path - generally it tries to stay on the "fast" path as much as possible. * * The overall complexity of the algorithm is O(n + m) for speed and O(n) for memory (where n is the * length of the live collection and m is the length of the incoming collection). Given the problem * at hand the complexity / performance constraints makes it impossible to perform the absolute * minimum of operation to reconcile the 2 collections. The algorithm makes different tradeoffs to * stay within reasonable performance bounds and may apply sub-optimal number of operations in * certain situations. * * @param liveCollection the current, live collection; * @param newCollection the new, incoming collection; * @param trackByFn key generation function that determines equality between items in the life and * incoming collection; */ declare function reconcile(liveCollection: LiveCollection, newCollection: Iterable | undefined | null, trackByFn: TrackByFunction): void; interface RxListViewComputedContext { index: number; count: number; } interface RxListViewContext extends RxListViewComputedContext { $implicit: T; item$: Observable; updateContext(newProps: Partial): void; } declare class RxDefaultListViewContext = NgIterable, K = keyof T> implements RxListViewContext { readonly _item: ReplaySubject; item$: Observable; private _$implicit; private _$complete; private _$error; private _$suspense; private readonly _context$; set $implicit($implicit: T); get $implicit(): T; get $complete(): boolean; get $error(): false | Error; get $suspense(): any; get index(): number; get count(): number; get first(): boolean; get last(): boolean; get even(): boolean; get odd(): boolean; get index$(): Observable; get count$(): Observable; get first$(): Observable; get last$(): Observable; get even$(): Observable; get odd$(): Observable; constructor(item: T, customProps?: { count: number; index: number; }); updateContext(newProps: Partial): void; select: (props: K[]) => Observable; } type rxBaseTemplateNames = 'errorTpl' | 'completeTpl' | 'suspenseTpl'; declare enum RxBaseTemplateNames { error = "errorTpl", complete = "completeTpl", suspense = "suspenseTpl" } interface RxViewContext { $implicit: T; error: boolean | Error; complete: boolean; suspense: boolean; } interface RxRenderAware { nextStrategy: (nextConfig: string | Observable) => void; render: (values$: Observable>) => Observable; } interface RxRenderSettings { cdRef: ChangeDetectorRef; parent: boolean; patchZone: NgZone | false; strategies: RxStrategies; defaultStrategyName: string; errorHandler?: ErrorHandler; } type CreateViewContext = (value: T, computedContext: U) => C; type UpdateViewContext = (value: T, view: EmbeddedViewRef, computedContext?: U) => void; interface RxTemplateSettings { viewContainerRef: ViewContainerRef; customContext?: (value: T) => Partial; } interface RxListTemplateSettings { viewContainerRef: ViewContainerRef; createViewContext: CreateViewContext; updateViewContext: UpdateViewContext; initialTemplateRef?: TemplateRef; } interface RxListManager { nextStrategy: (config: RxStrategyNames | Observable) => void; render(changes$: Observable>): Observable | null>; } declare function createListTemplateManager>(config: { renderSettings: RxRenderSettings; templateSettings: RxListTemplateSettings & { templateRef: TemplateRef; }; trackBy: TrackByFunction; iterableDiffers: IterableDiffers; }): RxListManager; type View = EmbeddedViewRef> & { _tempView?: boolean; }; declare class RxLiveCollection extends LiveCollection, T> { private viewContainer; private templateRef; private strategyProvider; private createViewContext; private updateViewContext; /** Property indicating if indexes in the repeater context need to be updated following the live collection changes. Index updates are necessary if and only if views are inserted / removed in the middle of LContainer. Adds and removals at the end don't require index updates. */ private needsIndexUpdate; private _needHostUpdate; private set needHostUpdate(value); get needHostUpdate(): boolean; private lastCount; private workQueue; private _virtualViews; constructor(viewContainer: ViewContainerRef, templateRef: TemplateRef<{ $implicit: unknown; index: number; }>, strategyProvider: RxStrategyProvider, createViewContext: (item: T, context: RxListViewComputedContext) => RxDefaultListViewContext, updateViewContext: (item: T, view: View, context: RxListViewComputedContext) => void); flushQueue(strategy: RxStrategyNames, ngZone?: NgZone): rxjs.Observable; get length(): number; at(index: number): T; attach(index: number, view: View): void; private attachView; detach(index: number): View; private detachView; create(index: number, value: T): View; destroy(view: View): void; private destroyView; updateValue(index: number, value: T): void; private updateView; reset(): void; updateIndexes(): void; private getView; } interface RxTemplateManager, N = rxBaseTemplateNames | string> extends RxRenderAware { addTemplateRef: (name: N, templateRef: TemplateRef) => void; } type RxNotificationTemplateNameMap = Record TemplateRef; }) => N>; declare function createTemplateManager, N extends string = string>(config: { renderSettings: RxRenderSettings; templateSettings: RxTemplateSettings; templateTrigger$?: Observable; notificationToTemplateName: RxNotificationTemplateNameMap; }): RxTemplateManager; /** * @internal * * A factory function returning an object to handle `TemplateRef`'s. * You can add and get a `TemplateRef`. * */ declare function templateHandling(viewContainerRef: ViewContainerRef): { add(name: N, templateRef: TemplateRef): void; get(name: N): TemplateRef; get$(name: N): Observable>; createEmbeddedView(name: N, context?: C, index?: number): EmbeddedViewRef; }; export { LiveCollection, RxBaseTemplateNames, RxDefaultListViewContext, RxLiveCollection, createListTemplateManager, createTemplateManager, reconcile, templateHandling }; export type { RxListManager, RxListViewComputedContext, RxListViewContext, RxNotificationTemplateNameMap, RxRenderAware, RxTemplateManager, RxViewContext, rxBaseTemplateNames };