projects/i-components/src/lib/services/change-dection-notifier.service.ts
Properties |
|
Methods |
Accessors |
applicationDetectChanges | ||||||
applicationDetectChanges(cdRef: ChangeDetectorRef)
|
||||||
Performs an application changes detection action to update the UI against possible changes
Parameters :
Returns :
void
|
notifyDetectChanges | ||||||
notifyDetectChanges(component: BaseComponent)
|
||||||
Notify XamTile current state changed
Parameters :
Returns :
void
|
Private changeDetectionService |
Type : Subject<any>
|
Default value : new Subject<any>()
|
Subject service for change detection |
timeout |
Type : any
|
Timeout to debounce the change detection action |
timer |
Type : number
|
Default value : 50
|
Time before triggering the change detection |
changeDetectionAction |
getchangeDetectionAction()
|
Subscription event to handle the XamTile state changed
Returns :
Observable<any>
|
import { ChangeDetectorRef, Injectable } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import { BaseComponent } from '../components/base/base.component';
@Injectable({
providedIn: 'root',
})
export class ChangeDectionNotifierService {
/**
* Time before triggering the change detection
*
* @memberof ChangeDectionNotifierService
*/
timer = 50;
/**
* Timeout to debounce the change detection action
*
* @type {*}
* @memberof ChangeDectionNotifierService
*/
timeout: any;
/**
* Subject service for change detection
*
* @private
* @type {Subject<any>}
* @memberof BaseComponent
*/
private changeDetectionService: Subject<any> = new Subject<any>();
/**
* Subscription event to handle the XamTile state changed
*
* @readonly
* @type {Observable<XamTileComponent>}
* @memberof XamTileManagerService
*/
get changeDetectionAction(): Observable<any> {
return this.changeDetectionService.asObservable();
}
/**
* Notify XamTile current state changed
*
* @param {*} void
* @memberof XamTileManagerService
*/
notifyDetectChanges(component: BaseComponent): void {
this.changeDetectionService.next(component);
}
/**
* Performs an application changes detection action to
* update the UI against possible changes
*
* @memberof ChangeDectionNotifierService
*/
applicationDetectChanges(cdRef: ChangeDetectorRef): void {
/* istanbul ignore else */
if (!cdRef['destroyed']) {
cdRef.detectChanges();
}
}
}