UNPKG

@rxap/remote-method

Version:

This package provides abstractions for defining and executing remote methods in Angular applications. It includes features such as automatic refreshing, proxying, and error handling. It offers a structured way to manage remote calls and their dependencies

119 lines (118 loc) 5.69 kB
import { ChangeDetectorRef, DoCheck, Injector, IterableChanges, IterableDiffers, NgZone, OnChanges, OnInit, SimpleChanges, TemplateRef, TrackByFunction, ViewContainerRef } from '@angular/core'; import { BaseRemoteMethod, BaseRemoteMethodMetadata, RemoteMethodLoader } from '@rxap/remote-method'; import { IdOrInstanceOrToken } from '@rxap/definition'; import * as i0 from "@angular/core"; export declare class RemoteMethodTemplateCollectionDirectiveContext<ReturnType = any> { $implicit: ReturnType; index: number; count: number; constructor($implicit: ReturnType, index: number, count: number); get first(): boolean; get last(): boolean; get even(): boolean; get odd(): boolean; } export interface RemoteMethodTemplateCollectionDirectiveErrorContext { $implicit: Error; message?: string; name?: string; } export declare class RemoteMethodTemplateCollectionDirective<ReturnType = any, Parameters = any, Metadata extends BaseRemoteMethodMetadata = BaseRemoteMethodMetadata> implements OnChanges, DoCheck, OnInit { private readonly template; protected readonly remoteMethodLoader: RemoteMethodLoader; private readonly injector; private readonly viewContainerRef; protected readonly cdr: ChangeDetectorRef; private readonly differs; private readonly zone; private readonly remoteMethodToken?; parameters?: Parameters; emptyTemplate?: TemplateRef<void>; errorTemplate?: TemplateRef<RemoteMethodTemplateCollectionDirectiveErrorContext>; withoutParameters: boolean; private _differ; private _trackByFn; private _dirty; /** * Indicates that the remote method returned a empty collection * * true - is empty * false - is NOT empty * null - unknown * * @private */ private _empty; /** * Holds the error that call of the remote method throws * * @private */ private _error; /** * Holds the empty template view ref. * * Is used to determine if a empty template is added to the * view. And used to destruct the empty template if the remote method * changes from empty to not empty. * * @private */ private _emptyTemplateViewRef; /** * Holds the error template view ref. * * Is used to determine if a error template is added to the * view. And used to destruct the error template if the remote method * is called again with an error. * * @private */ private _errorTemplateViewRef; constructor(template: TemplateRef<RemoteMethodTemplateCollectionDirectiveContext<ReturnType>>, remoteMethodLoader: RemoteMethodLoader, injector: Injector, viewContainerRef: ViewContainerRef, cdr: ChangeDetectorRef, differs: IterableDiffers, zone: NgZone, remoteMethodToken?: any | undefined); get trackBy(): TrackByFunction<ReturnType>; /** * A function that defines how to track changes for items in the iterable. * * When items are added, moved, or removed in the iterable, * the directive must re-render the appropriate DOM nodes. * To minimize churn in the DOM, only nodes that have changed * are re-rendered. * * By default, the change detector assumes that * the object instance identifies the node in the iterable. * When this function is supplied, the directive uses * the result of calling this function to identify the item node, * rather than the identity of the object itself. * * The function receives two inputs, * the iteration index and the node object ID. */ set trackBy(fn: TrackByFunction<ReturnType>); protected _remoteMethodOrIdOrToken: IdOrInstanceOrToken<BaseRemoteMethod<ReturnType[], Parameters, Metadata>>; set remoteMethodOrIdOrToken(value: IdOrInstanceOrToken<BaseRemoteMethod<ReturnType[], Parameters, Metadata>>); /** * Holds the data that should be displayed * @private */ private _data; protected set data(data: ReturnType[]); /** * Asserts the correct type of the context for the template that `NgForOf` will render. * * The presence of this method is a signal to the Ivy template type-check compiler that the * `NgForOf` structural directive renders its template with a specific context type. */ static ngTemplateContextGuard<T>(dir: RemoteMethodTemplateCollectionDirective<T>, ctx: any): ctx is RemoteMethodTemplateCollectionDirectiveContext<T>; ngOnChanges(changes: SimpleChanges): void; ngOnInit(): void; call(parameters?: Parameters): void; /** * Applies the changes when needed. */ ngDoCheck(): void; protected applyChanges(changes: IterableChanges<ReturnType>): void; private perViewChange; static ɵfac: i0.ɵɵFactoryDeclaration<RemoteMethodTemplateCollectionDirective<any, any, any>, [null, null, null, null, null, null, null, { optional: true; self: true; }]>; static ɵdir: i0.ɵɵDirectiveDeclaration<RemoteMethodTemplateCollectionDirective<any, any, any>, "[rxapRemoteMethodCollection]", ["rxapRemoteMethodCollection"], { "parameters": { "alias": "rxapRemoteMethodCollectionParameters"; "required": false; }; "emptyTemplate": { "alias": "rxapRemoteMethodCollectionEmpty"; "required": false; }; "errorTemplate": { "alias": "rxapRemoteMethodCollectionError"; "required": false; }; "withoutParameters": { "alias": "rxapRemoteMethodCollectionWithoutParameters"; "required": false; }; "trackBy": { "alias": "rxapRemoteMethodCollectionTrackBy"; "required": false; }; "remoteMethodOrIdOrToken": { "alias": "rxapRemoteMethodCollectionCall"; "required": false; }; }, {}, never, never, true, never>; }