@bespunky/angular-zen
Version:
The Angular tools you always wished were there.
58 lines (57 loc) • 2.87 kB
TypeScript
import { Observable } from 'rxjs';
import { ObserveBaseDirective } from '../abstraction/observe-base.directive';
import { EmittedTypeOf, ResolvedObserveContext } from '../abstraction/types/general';
import * as i0 from "@angular/core";
declare type ObserveContext<T extends Observable<unknown>> = ResolvedObserveContext<EmittedTypeOf<T>> & {
observe: EmittedTypeOf<T>;
};
/**
* Documentation in {@link ObserveDirective.observe} to allow in-template tooltips.
*
* @export
* @class ObserveDirective
* @extends {ObserveBaseDirective<T, EmittedTypeOf<T>, ObserveContext<T>>}
* @template T The type of observable received by the directive.
*/
export declare class ObserveDirective<T extends Observable<unknown>> extends ObserveBaseDirective<T, EmittedTypeOf<T>, ObserveContext<T>> {
protected selector: string;
/**
* Tracks an observable and updates the template with its emitted value on each emission.
*
* Any template assigned with the directive will render immediately, and its view context will be updated with the emitted value on
* each emission. The directive will be responsible for subscribing on init and unsubscribing on destroy.
*
* ## Features
*
* #### Shared observable
* The watched observable will automatically be multicasted so that any child observables created by the template will use the same
* stream.
*
* The shared observable can be accessed using the `let source = source` microsyntax.
*
* #### Observer events
* Whenever the observable changes state or emits a value, the corresponding event is emitted:
* `nextCalled` - A value has been emitted. `$event` will be the emitted value.
* `errorCalled` - An error has occured in the pipeline. `$event` will be the error.
* `completeCalled` - The observable has completed. `$event` will be void.
*
* > Because of limitations to Angular's Structural Directives, in order to bind the events the desugared syntax must be used.
* This, for example, **will trigger** the event:
* > ```html
* ><ng-template [observe]="x$" let-source="source" (nextCalled)="onNext($event)">
* > ...
* ></ng-template>
* > ```
* >
* >This **will NOT trigger** the event:
* >```html
* > <div *observe="x$; let source = source" (nextCalled)="onNext($event)">...</div>
* >```
*/
set observe(value: T);
static ngTemplateContextGuard<T extends Observable<unknown>>(directive: ObserveDirective<T>, context: unknown): context is ObserveContext<T>;
protected observeInput(input: T): Observable<EmittedTypeOf<T>>;
static ɵfac: i0.ɵɵFactoryDeclaration<ObserveDirective<any>, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<ObserveDirective<any>, "[observe]", never, { "observe": "observe"; }, {}, never, never, false>;
}
export {};