core/src/rxjs/observe/directives/observe-concat.directive.ts
Documentation in ObserveConcatDirective.observeConcat to allow in-template tooltips.
| Selector | [observeConcat] |
Properties |
|
Methods |
|
Inputs |
Outputs |
Accessors |
| observeConcat | |
Type : T
|
|
|
Concats an array of observables using rxjs concat() and exposes the emitted values to the template. 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. FeaturesShared observableThe 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 Observer eventsWhenever the observable changes state or emits a value, the corresponding event is emitted:
|
|
| completeCalled | |
Type : EventEmitter<void>
|
|
|
Inherited from
ObserveBaseDirective
|
|
|
Defined in
ObserveBaseDirective:81
|
|
|
Triggered when the observable completes. |
|
| errorCalled | |
Type : EventEmitter<>
|
|
|
Inherited from
ObserveBaseDirective
|
|
|
Defined in
ObserveBaseDirective:75
|
|
|
Triggered when an error occurs in the observable's pipeline. |
|
| nextCalled | |
Type : EventEmitter<TResolved>
|
|
|
Inherited from
ObserveBaseDirective
|
|
|
Defined in
ObserveBaseDirective:69
|
|
|
Triggered whenever the observable emits a value. |
|
| Static ngTemplateContextGuard | |||||||||
ngTemplateContextGuard(directive: ObserveConcatDirective<T>, context)
|
|||||||||
Type parameters:
|
|||||||||
|
Parameters:
Returns:
ObserveConcatContext<T>
|
|||||||||
| Protected observeInput | ||||||
observeInput(input: T)
|
||||||
|
Inherited from
ObserveBaseDirective
|
||||||
|
Parameters:
Returns:
Observable<EmittedArrayTypesOf<T>>
|
||||||
| Protected createViewContext | |||||
createViewContext(undefined: literal type)
|
|||||
|
Inherited from
ObserveBaseDirective
|
|||||
|
Parameters:
Returns:
TContext
|
|||||
| ngOnInit |
ngOnInit()
|
|
Inherited from
ObserveBaseDirective
|
|
Returns:
void
|
| ngOnDestroy |
ngOnDestroy()
|
|
Inherited from
Destroyable
|
|
Returns:
void
|
| Protected subscribe | ||||||||||||||||||||
subscribe(observable: Observable
|
||||||||||||||||||||
|
Inherited from
Destroyable
|
||||||||||||||||||||
Type parameters:
|
||||||||||||||||||||
|
Subscribes to an observable and stores the subscription for automatic disposal.
When
Parameters:
Returns:
Subscription
The subscription created for the observable. |
||||||||||||||||||||
| Protected selector |
Type: string
|
Default value: 'observeConcat'
|
|
Inherited from
ObserveBaseDirective
|
| Protected Readonly input |
Type: BehaviorSubject<TInput | null>
|
Default value: new BehaviorSubject(null as TInput | null)
|
|
Inherited from
ObserveBaseDirective
|
Why BehaviorSubject<s | null> and not Subject<TInput>
This leads to subscribing in ngOnInit, to allow Angular time to initialize those.
BUT, if |
| Protected Readonly destroyed |
Type: Subject<void>
|
Default value: new Subject()
|
|
Inherited from
Destroyable
|
|
Emits a value when |
| Protected Readonly subscriptions |
Type: Subscription
|
Default value: new Subscription()
|
|
Inherited from
Destroyable
|
|
A list of all subscriptions manually added using the |
| observeConcat | ||||||
setobserveConcat(value: T)
|
||||||
|
Concats an array of observables using rxjs concat() and exposes the emitted values to the template. 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. FeaturesShared observableThe 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 Observer eventsWhenever the observable changes state or emits a value, the corresponding event is emitted:
Parameters :
Returns:
void
|
||||||
import { Observable, concat } from 'rxjs';
import { Directive, Input } from '@angular/core';
import { ObserveArrayDirective } from '../abstraction/observe-array-base.directive';
import { ResolvedObserveContext } from '../abstraction/types/general';
import { EmittedArrayTypesOf } from '../abstraction/types/arrays';
type ObserveConcatContext<TInput extends Observable<unknown>[]> = ResolvedObserveContext<EmittedArrayTypesOf<TInput>> & {
observeConcat: EmittedArrayTypesOf<TInput>
};
/**
* Documentation in {@link ObserveConcatDirective.observeConcat} to allow in-template tooltips.
*
* @export
* @class ObserveConcatDirective
* @extends {ObserveArrayDirective<T, EmittedArrayTypesOf<T>, ObserveConcatContext<T>>}
* @template T The type of observables tuple received by the directive.
*/
@Directive({
selector: '[observeConcat]'
})
export class ObserveConcatDirective<T extends Observable<unknown>[]>
extends ObserveArrayDirective<T, EmittedArrayTypesOf<T>, ObserveConcatContext<T>>
{
protected selector = 'observeConcat';
/**
* Concats an array of observables using rxjs {@link https://rxjs.dev/api/index/function/concat concat()} and exposes the emitted values to the template.
*
* 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>
* >```
*/
@Input() public set observeConcat(value: T) { this.input.next(value); }
static ngTemplateContextGuard<T extends Observable<unknown>[]>(directive: ObserveConcatDirective<T>, context: unknown): context is ObserveConcatContext<T> { return true; }
protected observeInput(input: T): Observable<EmittedArrayTypesOf<T>>
{
return concat(...input) as Observable<EmittedArrayTypesOf<T>>;
}
}