"import {MonoTypeOperatorFunction, Observable} from 'rxjs';\r\nimport {takeUntil} from 'rxjs/operators';\r\n\r\n// create a symbol identify the observable I add to\r\n// the component so it doesn't conflict with anything.\r\n// I need this so I'm able to add the desired behaviour to the component.\r\nexport const destroy$ = Symbol('destroy$');\r\n\r\n/**\r\n * An operator that takes until destroy it takes a components this a parameter\r\n * returns a pipeable RxJS operator.\r\n */\r\nexport const untilDestroy = <T>(component: any): MonoTypeOperatorFunction<T> => {\r\n if (component[destroy$] === undefined) {\r\n // only hookup each component once.\r\n addDestroyObservableToComponent(component);\r\n }\r\n\r\n // pipe in the takeUntil destroy$ and return the source unaltered\r\n return takeUntil<T>(component[destroy$]);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function addDestroyObservableToComponent(component: any) {\r\n component[destroy$] = new Observable<void>(observer => {\r\n // keep track of the original destroy function,\r\n // the user might do something in there\r\n const orignalDestroy = component.ngOnDestroy;\r\n if (orignalDestroy == null) {\r\n // Angular does not support dynamic added destroy methods\r\n // so make sure there is one.\r\n throw new Error('untilDestroy operator needs the component to have an ngOnDestroy method');\r\n }\r\n // replace the ngOndestroy\r\n component.ngOnDestroy = () => {\r\n // fire off the destroy observable\r\n observer.next();\r\n // complete the observable\r\n observer.complete();\r\n // and at last, call the original destroy\r\n orignalDestroy.call(component);\r\n };\r\n // return cleanup function.\r\n return (_: any) => (component[destroy$] = undefined);\r\n });\r\n}\r\n",
"import {Observable} from 'rxjs';\r\nimport {takeUntil} from 'rxjs/operators';\r\nimport { MonoTypeOperatorFunction } from 'rxjs/interfaces';\r\n\r\n// create a symbol identify the observable I add to\r\n// the component so it doesn't conflict with anything.\r\n// I need this so I'm able to add the desired behaviour to the component.\r\nexport const destroy$ = Symbol('destroy$');\r\n\r\n/**\r\n * An operator that takes until destroy it takes a components this a parameter\r\n * returns a pipeable RxJS operator.\r\n */\r\nexport const untilDestroy = <T>(component: any): MonoTypeOperatorFunction<T> => {\r\n if (component[destroy$] === undefined) {\r\n // only hookup each component once.\r\n addDestroyObservableToComponent(component);\r\n }\r\n\r\n // pipe in the takeUntil destroy$ and return the source unaltered\r\n return takeUntil<T>(component[destroy$]);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function addDestroyObservableToComponent(component: any) {\r\n component[destroy$] = new Observable<void>(observer => {\r\n // keep track of the original destroy function,\r\n // the user might do something in there\r\n const orignalDestroy = component.ngOnDestroy;\r\n if (orignalDestroy == null) {\r\n // Angular does not support dynamic added destroy methods\r\n // so make sure there is one.\r\n throw new Error('untilDestroy operator needs the component to have an ngOnDestroy method');\r\n }\r\n // replace the ngOndestroy\r\n component.ngOnDestroy = () => {\r\n // fire off the destroy observable\r\n observer.next();\r\n // complete the observable\r\n observer.complete();\r\n // and at last, call the original destroy\r\n orignalDestroy.call(component);\r\n };\r\n // return cleanup function.\r\n return (_: any) => (component[destroy$] = undefined);\r\n });\r\n}\r\n",
"import {Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, OnInit, Output, PLATFORM_ID,} from '@angular/core';\r\nimport {isPlatformBrowser} from '@angular/common';\r\nimport {filter, take} from 'rxjs/operators';\r\nimport {ViewportService} from '../services';\r\nimport {untilDestroy} from '../operators';\r\n\r\n@Directive({\r\n selector: '[aiutInViewport]',\r\n})\r\nexport class InViewportDirective implements OnInit, OnDestroy {\r\n @Input() public preRender = true;\r\n @Input() public oneTime = false;\r\n @Output() readonly inViewport = new EventEmitter<Partial<IntersectionObserverEntry>>();\r\n\r\n constructor(\r\n private readonly elementRef: ElementRef,\r\n private viewportService: ViewportService,\r\n @Inject(PLATFORM_ID) private platformId: Object,\r\n ) {\r\n }\r\n\r\n public ngOnInit() {\r\n if (isPlatformBrowser(this.platformId)) {\r\n if (this.oneTime) {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(\r\n untilDestroy(this),\r\n filter(entry => entry.intersectionRatio >= 0.5),\r\n take(1),\r\n )\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n } else {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(untilDestroy(this))\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n }\r\n } else {\r\n if (this.preRender) {\r\n this.inViewport.emit({isIntersecting: true, intersectionRatio: 1});\r\n }\r\n }\r\n }\r\n\r\n ngOnDestroy() {\r\n }\r\n}\r\n",
"import {Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, OnInit, Output, PLATFORM_ID,} from '@angular/core';\r\nimport {isPlatformBrowser} from '@angular/common';\r\nimport {filter, take} from 'rxjs/operators';\r\nimport {ViewportService} from '../services';\r\nimport {untilDestroy} from '../operators';\r\n\r\n@Directive({\r\n selector: '[aiutInViewport]',\r\n})\r\nexport class InViewportDirective implements OnInit, OnDestroy {\r\n @Input() public preRender = true;\r\n @Input() public oneTime = false;\r\n @Output() readonly inViewport = new EventEmitter<Partial<IntersectionObserverEntry>>();\r\n\r\n constructor(\r\n private readonly elementRef: ElementRef,\r\n private viewportService: ViewportService,\r\n @Inject(PLATFORM_ID) private platformId: Object,\r\n ) {\r\n }\r\n\r\n public ngOnInit() {\r\n if (isPlatformBrowser(this.platformId)) {\r\n if (this.oneTime) {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(\r\n untilDestroy(this),\r\n filter(entry => entry.intersectionRatio >= 0.5),\r\n take(1),\r\n )\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n } else {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(untilDestroy(this))\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n }\r\n } else {\r\n if (this.preRender) {\r\n this.inViewport.emit({isIntersecting: true, intersectionRatio: 1});\r\n }\r\n }\r\n }\r\n\r\n ngOnDestroy() {\r\n }\r\n}\r\n",
"import {NgModule} from '@angular/core';\r\nimport {CommonModule} from '@angular/common';\r\n\r\nimport * as Components from './components';\r\nimport * as Directives from './directives';\r\nimport * as Services from './services';\r\n\r\n@NgModule({\r\n imports: [CommonModule],\r\n declarations: [Directives.InViewportDirective, Components.InViewportComponent],\r\n providers: [Services.ViewportService],\r\n exports: [Directives.InViewportDirective, Components.InViewportComponent]\r\n})\r\nexport class AitpUtilsModule { }\r\n"
"import {NgModule} from '@angular/core';\r\nimport {CommonModule} from '@angular/common';\r\n\r\nimport * as Components from './components';\r\nimport * as Directives from './directives';\r\nimport * as Services from './services';\r\n\r\n@NgModule({\r\n imports: [CommonModule],\r\n declarations: [Directives.InViewportDirective, Components.InViewportComponent],\r\n providers: [Services.ViewportService],\r\n exports: [Directives.InViewportDirective, Components.InViewportComponent]\r\n})\r\nexport class AitpUtilsModule { }\r\n"
"import {MonoTypeOperatorFunction, Observable} from 'rxjs';\r\nimport {takeUntil} from 'rxjs/operators';\r\n\r\n// create a symbol identify the observable I add to\r\n// the component so it doesn't conflict with anything.\r\n// I need this so I'm able to add the desired behaviour to the component.\r\nexport const destroy$ = Symbol('destroy$');\r\n\r\n/**\r\n * An operator that takes until destroy it takes a components this a parameter\r\n * returns a pipeable RxJS operator.\r\n */\r\nexport const untilDestroy = <T>(component: any): MonoTypeOperatorFunction<T> => {\r\n if (component[destroy$] === undefined) {\r\n // only hookup each component once.\r\n addDestroyObservableToComponent(component);\r\n }\r\n\r\n // pipe in the takeUntil destroy$ and return the source unaltered\r\n return takeUntil<T>(component[destroy$]);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function addDestroyObservableToComponent(component: any) {\r\n component[destroy$] = new Observable<void>(observer => {\r\n // keep track of the original destroy function,\r\n // the user might do something in there\r\n const orignalDestroy = component.ngOnDestroy;\r\n if (orignalDestroy == null) {\r\n // Angular does not support dynamic added destroy methods\r\n // so make sure there is one.\r\n throw new Error('untilDestroy operator needs the component to have an ngOnDestroy method');\r\n }\r\n // replace the ngOndestroy\r\n component.ngOnDestroy = () => {\r\n // fire off the destroy observable\r\n observer.next();\r\n // complete the observable\r\n observer.complete();\r\n // and at last, call the original destroy\r\n orignalDestroy.call(component);\r\n };\r\n // return cleanup function.\r\n return (_: any) => (component[destroy$] = undefined);\r\n });\r\n}\r\n",
"import {Observable} from 'rxjs';\r\nimport {takeUntil} from 'rxjs/operators';\r\nimport { MonoTypeOperatorFunction } from 'rxjs/interfaces';\r\n\r\n// create a symbol identify the observable I add to\r\n// the component so it doesn't conflict with anything.\r\n// I need this so I'm able to add the desired behaviour to the component.\r\nexport const destroy$ = Symbol('destroy$');\r\n\r\n/**\r\n * An operator that takes until destroy it takes a components this a parameter\r\n * returns a pipeable RxJS operator.\r\n */\r\nexport const untilDestroy = <T>(component: any): MonoTypeOperatorFunction<T> => {\r\n if (component[destroy$] === undefined) {\r\n // only hookup each component once.\r\n addDestroyObservableToComponent(component);\r\n }\r\n\r\n // pipe in the takeUntil destroy$ and return the source unaltered\r\n return takeUntil<T>(component[destroy$]);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function addDestroyObservableToComponent(component: any) {\r\n component[destroy$] = new Observable<void>(observer => {\r\n // keep track of the original destroy function,\r\n // the user might do something in there\r\n const orignalDestroy = component.ngOnDestroy;\r\n if (orignalDestroy == null) {\r\n // Angular does not support dynamic added destroy methods\r\n // so make sure there is one.\r\n throw new Error('untilDestroy operator needs the component to have an ngOnDestroy method');\r\n }\r\n // replace the ngOndestroy\r\n component.ngOnDestroy = () => {\r\n // fire off the destroy observable\r\n observer.next();\r\n // complete the observable\r\n observer.complete();\r\n // and at last, call the original destroy\r\n orignalDestroy.call(component);\r\n };\r\n // return cleanup function.\r\n return (_: any) => (component[destroy$] = undefined);\r\n });\r\n}\r\n",
"import {Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, OnInit, Output, PLATFORM_ID,} from '@angular/core';\r\nimport {isPlatformBrowser} from '@angular/common';\r\nimport {filter, take} from 'rxjs/operators';\r\nimport {ViewportService} from '../services';\r\nimport {untilDestroy} from '../operators';\r\n\r\n@Directive({\r\n selector: '[aiutInViewport]',\r\n})\r\nexport class InViewportDirective implements OnInit, OnDestroy {\r\n @Input() public preRender = true;\r\n @Input() public oneTime = false;\r\n @Output() readonly inViewport = new EventEmitter<Partial<IntersectionObserverEntry>>();\r\n\r\n constructor(\r\n private readonly elementRef: ElementRef,\r\n private viewportService: ViewportService,\r\n @Inject(PLATFORM_ID) private platformId: Object,\r\n ) {\r\n }\r\n\r\n public ngOnInit() {\r\n if (isPlatformBrowser(this.platformId)) {\r\n if (this.oneTime) {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(\r\n untilDestroy(this),\r\n filter(entry => entry.intersectionRatio >= 0.5),\r\n take(1),\r\n )\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n } else {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(untilDestroy(this))\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n }\r\n } else {\r\n if (this.preRender) {\r\n this.inViewport.emit({isIntersecting: true, intersectionRatio: 1});\r\n }\r\n }\r\n }\r\n\r\n ngOnDestroy() {\r\n }\r\n}\r\n",
"import {Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, OnInit, Output, PLATFORM_ID,} from '@angular/core';\r\nimport {isPlatformBrowser} from '@angular/common';\r\nimport {filter, take} from 'rxjs/operators';\r\nimport {ViewportService} from '../services';\r\nimport {untilDestroy} from '../operators';\r\n\r\n@Directive({\r\n selector: '[aiutInViewport]',\r\n})\r\nexport class InViewportDirective implements OnInit, OnDestroy {\r\n @Input() public preRender = true;\r\n @Input() public oneTime = false;\r\n @Output() readonly inViewport = new EventEmitter<Partial<IntersectionObserverEntry>>();\r\n\r\n constructor(\r\n private readonly elementRef: ElementRef,\r\n private viewportService: ViewportService,\r\n @Inject(PLATFORM_ID) private platformId: Object,\r\n ) {\r\n }\r\n\r\n public ngOnInit() {\r\n if (isPlatformBrowser(this.platformId)) {\r\n if (this.oneTime) {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(\r\n untilDestroy(this),\r\n filter(entry => entry.intersectionRatio >= 0.5),\r\n take(1),\r\n )\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n } else {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(untilDestroy(this))\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n }\r\n } else {\r\n if (this.preRender) {\r\n this.inViewport.emit({isIntersecting: true, intersectionRatio: 1});\r\n }\r\n }\r\n }\r\n\r\n ngOnDestroy() {\r\n }\r\n}\r\n",
"import {NgModule} from '@angular/core';\r\nimport {CommonModule} from '@angular/common';\r\n\r\nimport * as Components from './components';\r\nimport * as Directives from './directives';\r\nimport * as Services from './services';\r\n\r\n@NgModule({\r\n imports: [CommonModule],\r\n declarations: [Directives.InViewportDirective, Components.InViewportComponent],\r\n providers: [Services.ViewportService],\r\n exports: [Directives.InViewportDirective, Components.InViewportComponent]\r\n})\r\nexport class AitpUtilsModule { }\r\n"
"import {NgModule} from '@angular/core';\r\nimport {CommonModule} from '@angular/common';\r\n\r\nimport * as Components from './components';\r\nimport * as Directives from './directives';\r\nimport * as Services from './services';\r\n\r\n@NgModule({\r\n imports: [CommonModule],\r\n declarations: [Directives.InViewportDirective, Components.InViewportComponent],\r\n providers: [Services.ViewportService],\r\n exports: [Directives.InViewportDirective, Components.InViewportComponent]\r\n})\r\nexport class AitpUtilsModule { }\r\n"
"import {MonoTypeOperatorFunction, Observable} from 'rxjs';\r\nimport {takeUntil} from 'rxjs/operators';\r\n\r\n// create a symbol identify the observable I add to\r\n// the component so it doesn't conflict with anything.\r\n// I need this so I'm able to add the desired behaviour to the component.\r\nexport const destroy$ = Symbol('destroy$');\r\n\r\n/**\r\n * An operator that takes until destroy it takes a components this a parameter\r\n * returns a pipeable RxJS operator.\r\n */\r\nexport const untilDestroy = <T>(component: any): MonoTypeOperatorFunction<T> => {\r\n if (component[destroy$] === undefined) {\r\n // only hookup each component once.\r\n addDestroyObservableToComponent(component);\r\n }\r\n\r\n // pipe in the takeUntil destroy$ and return the source unaltered\r\n return takeUntil<T>(component[destroy$]);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function addDestroyObservableToComponent(component: any) {\r\n component[destroy$] = new Observable<void>(observer => {\r\n // keep track of the original destroy function,\r\n // the user might do something in there\r\n const orignalDestroy = component.ngOnDestroy;\r\n if (orignalDestroy == null) {\r\n // Angular does not support dynamic added destroy methods\r\n // so make sure there is one.\r\n throw new Error('untilDestroy operator needs the component to have an ngOnDestroy method');\r\n }\r\n // replace the ngOndestroy\r\n component.ngOnDestroy = () => {\r\n // fire off the destroy observable\r\n observer.next();\r\n // complete the observable\r\n observer.complete();\r\n // and at last, call the original destroy\r\n orignalDestroy.call(component);\r\n };\r\n // return cleanup function.\r\n return (_: any) => (component[destroy$] = undefined);\r\n });\r\n}\r\n",
"import {Observable} from 'rxjs';\r\nimport {takeUntil} from 'rxjs/operators';\r\nimport { MonoTypeOperatorFunction } from 'rxjs/interfaces';\r\n\r\n// create a symbol identify the observable I add to\r\n// the component so it doesn't conflict with anything.\r\n// I need this so I'm able to add the desired behaviour to the component.\r\nexport const destroy$ = Symbol('destroy$');\r\n\r\n/**\r\n * An operator that takes until destroy it takes a components this a parameter\r\n * returns a pipeable RxJS operator.\r\n */\r\nexport const untilDestroy = <T>(component: any): MonoTypeOperatorFunction<T> => {\r\n if (component[destroy$] === undefined) {\r\n // only hookup each component once.\r\n addDestroyObservableToComponent(component);\r\n }\r\n\r\n // pipe in the takeUntil destroy$ and return the source unaltered\r\n return takeUntil<T>(component[destroy$]);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function addDestroyObservableToComponent(component: any) {\r\n component[destroy$] = new Observable<void>(observer => {\r\n // keep track of the original destroy function,\r\n // the user might do something in there\r\n const orignalDestroy = component.ngOnDestroy;\r\n if (orignalDestroy == null) {\r\n // Angular does not support dynamic added destroy methods\r\n // so make sure there is one.\r\n throw new Error('untilDestroy operator needs the component to have an ngOnDestroy method');\r\n }\r\n // replace the ngOndestroy\r\n component.ngOnDestroy = () => {\r\n // fire off the destroy observable\r\n observer.next();\r\n // complete the observable\r\n observer.complete();\r\n // and at last, call the original destroy\r\n orignalDestroy.call(component);\r\n };\r\n // return cleanup function.\r\n return (_: any) => (component[destroy$] = undefined);\r\n });\r\n}\r\n",
"import {Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, OnInit, Output, PLATFORM_ID,} from '@angular/core';\r\nimport {isPlatformBrowser} from '@angular/common';\r\nimport {filter, take} from 'rxjs/operators';\r\nimport {ViewportService} from '../services';\r\nimport {untilDestroy} from '../operators';\r\n\r\n@Directive({\r\n selector: '[aiutInViewport]',\r\n})\r\nexport class InViewportDirective implements OnInit, OnDestroy {\r\n @Input() public preRender = true;\r\n @Input() public oneTime = false;\r\n @Output() readonly inViewport = new EventEmitter<Partial<IntersectionObserverEntry>>();\r\n\r\n constructor(\r\n private readonly elementRef: ElementRef,\r\n private viewportService: ViewportService,\r\n @Inject(PLATFORM_ID) private platformId: Object,\r\n ) {\r\n }\r\n\r\n public ngOnInit() {\r\n if (isPlatformBrowser(this.platformId)) {\r\n if (this.oneTime) {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(\r\n untilDestroy(this),\r\n filter(entry => entry.intersectionRatio >= 0.5),\r\n take(1),\r\n )\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n } else {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(untilDestroy(this))\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n }\r\n } else {\r\n if (this.preRender) {\r\n this.inViewport.emit({isIntersecting: true, intersectionRatio: 1});\r\n }\r\n }\r\n }\r\n\r\n ngOnDestroy() {\r\n }\r\n}\r\n",
"import {Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, OnInit, Output, PLATFORM_ID,} from '@angular/core';\r\nimport {isPlatformBrowser} from '@angular/common';\r\nimport {filter, take} from 'rxjs/operators';\r\nimport {ViewportService} from '../services';\r\nimport {untilDestroy} from '../operators';\r\n\r\n@Directive({\r\n selector: '[aiutInViewport]',\r\n})\r\nexport class InViewportDirective implements OnInit, OnDestroy {\r\n @Input() public preRender = true;\r\n @Input() public oneTime = false;\r\n @Output() readonly inViewport = new EventEmitter<Partial<IntersectionObserverEntry>>();\r\n\r\n constructor(\r\n private readonly elementRef: ElementRef,\r\n private viewportService: ViewportService,\r\n @Inject(PLATFORM_ID) private platformId: Object,\r\n ) {\r\n }\r\n\r\n public ngOnInit() {\r\n if (isPlatformBrowser(this.platformId)) {\r\n if (this.oneTime) {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(\r\n untilDestroy(this),\r\n filter(entry => entry.intersectionRatio >= 0.5),\r\n take(1),\r\n )\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n } else {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(untilDestroy(this))\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n }\r\n } else {\r\n if (this.preRender) {\r\n this.inViewport.emit({isIntersecting: true, intersectionRatio: 1});\r\n }\r\n }\r\n }\r\n\r\n ngOnDestroy() {\r\n }\r\n}\r\n",
"import {NgModule} from '@angular/core';\r\nimport {CommonModule} from '@angular/common';\r\n\r\nimport * as Components from './components';\r\nimport * as Directives from './directives';\r\nimport * as Services from './services';\r\n\r\n@NgModule({\r\n imports: [CommonModule],\r\n declarations: [Directives.InViewportDirective, Components.InViewportComponent],\r\n providers: [Services.ViewportService],\r\n exports: [Directives.InViewportDirective, Components.InViewportComponent]\r\n})\r\nexport class AitpUtilsModule { }\r\n"
"import {NgModule} from '@angular/core';\r\nimport {CommonModule} from '@angular/common';\r\n\r\nimport * as Components from './components';\r\nimport * as Directives from './directives';\r\nimport * as Services from './services';\r\n\r\n@NgModule({\r\n imports: [CommonModule],\r\n declarations: [Directives.InViewportDirective, Components.InViewportComponent],\r\n providers: [Services.ViewportService],\r\n exports: [Directives.InViewportDirective, Components.InViewportComponent]\r\n})\r\nexport class AitpUtilsModule { }\r\n"
"import {MonoTypeOperatorFunction, Observable} from 'rxjs';\r\nimport {takeUntil} from 'rxjs/operators';\r\n\r\n// create a symbol identify the observable I add to\r\n// the component so it doesn't conflict with anything.\r\n// I need this so I'm able to add the desired behaviour to the component.\r\nexport const destroy$ = Symbol('destroy$');\r\n\r\n/**\r\n * An operator that takes until destroy it takes a components this a parameter\r\n * returns a pipeable RxJS operator.\r\n */\r\nexport const untilDestroy = <T>(component: any): MonoTypeOperatorFunction<T> => {\r\n if (component[destroy$] === undefined) {\r\n // only hookup each component once.\r\n addDestroyObservableToComponent(component);\r\n }\r\n\r\n // pipe in the takeUntil destroy$ and return the source unaltered\r\n return takeUntil<T>(component[destroy$]);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function addDestroyObservableToComponent(component: any) {\r\n component[destroy$] = new Observable<void>(observer => {\r\n // keep track of the original destroy function,\r\n // the user might do something in there\r\n const orignalDestroy = component.ngOnDestroy;\r\n if (orignalDestroy == null) {\r\n // Angular does not support dynamic added destroy methods\r\n // so make sure there is one.\r\n throw new Error('untilDestroy operator needs the component to have an ngOnDestroy method');\r\n }\r\n // replace the ngOndestroy\r\n component.ngOnDestroy = () => {\r\n // fire off the destroy observable\r\n observer.next();\r\n // complete the observable\r\n observer.complete();\r\n // and at last, call the original destroy\r\n orignalDestroy.call(component);\r\n };\r\n // return cleanup function.\r\n return (_: any) => (component[destroy$] = undefined);\r\n });\r\n}\r\n",
"import {Observable} from 'rxjs';\r\nimport {takeUntil} from 'rxjs/operators';\r\nimport { MonoTypeOperatorFunction } from 'rxjs/interfaces';\r\n\r\n// create a symbol identify the observable I add to\r\n// the component so it doesn't conflict with anything.\r\n// I need this so I'm able to add the desired behaviour to the component.\r\nexport const destroy$ = Symbol('destroy$');\r\n\r\n/**\r\n * An operator that takes until destroy it takes a components this a parameter\r\n * returns a pipeable RxJS operator.\r\n */\r\nexport const untilDestroy = <T>(component: any): MonoTypeOperatorFunction<T> => {\r\n if (component[destroy$] === undefined) {\r\n // only hookup each component once.\r\n addDestroyObservableToComponent(component);\r\n }\r\n\r\n // pipe in the takeUntil destroy$ and return the source unaltered\r\n return takeUntil<T>(component[destroy$]);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function addDestroyObservableToComponent(component: any) {\r\n component[destroy$] = new Observable<void>(observer => {\r\n // keep track of the original destroy function,\r\n // the user might do something in there\r\n const orignalDestroy = component.ngOnDestroy;\r\n if (orignalDestroy == null) {\r\n // Angular does not support dynamic added destroy methods\r\n // so make sure there is one.\r\n throw new Error('untilDestroy operator needs the component to have an ngOnDestroy method');\r\n }\r\n // replace the ngOndestroy\r\n component.ngOnDestroy = () => {\r\n // fire off the destroy observable\r\n observer.next();\r\n // complete the observable\r\n observer.complete();\r\n // and at last, call the original destroy\r\n orignalDestroy.call(component);\r\n };\r\n // return cleanup function.\r\n return (_: any) => (component[destroy$] = undefined);\r\n });\r\n}\r\n",
"import {Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, OnInit, Output, PLATFORM_ID,} from '@angular/core';\r\nimport {isPlatformBrowser} from '@angular/common';\r\nimport {filter, take} from 'rxjs/operators';\r\nimport {ViewportService} from '../services';\r\nimport {untilDestroy} from '../operators';\r\n\r\n@Directive({\r\n selector: '[aiutInViewport]',\r\n})\r\nexport class InViewportDirective implements OnInit, OnDestroy {\r\n @Input() public preRender = true;\r\n @Input() public oneTime = false;\r\n @Output() readonly inViewport = new EventEmitter<Partial<IntersectionObserverEntry>>();\r\n\r\n constructor(\r\n private readonly elementRef: ElementRef,\r\n private viewportService: ViewportService,\r\n @Inject(PLATFORM_ID) private platformId: Object,\r\n ) {\r\n }\r\n\r\n public ngOnInit() {\r\n if (isPlatformBrowser(this.platformId)) {\r\n if (this.oneTime) {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(\r\n untilDestroy(this),\r\n filter(entry => entry.intersectionRatio >= 0.5),\r\n take(1),\r\n )\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n } else {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(untilDestroy(this))\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n }\r\n } else {\r\n if (this.preRender) {\r\n this.inViewport.emit({isIntersecting: true, intersectionRatio: 1});\r\n }\r\n }\r\n }\r\n\r\n ngOnDestroy() {\r\n }\r\n}\r\n",
"import {Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, OnInit, Output, PLATFORM_ID,} from '@angular/core';\r\nimport {isPlatformBrowser} from '@angular/common';\r\nimport {filter, take} from 'rxjs/operators';\r\nimport {ViewportService} from '../services';\r\nimport {untilDestroy} from '../operators';\r\n\r\n@Directive({\r\n selector: '[aiutInViewport]',\r\n})\r\nexport class InViewportDirective implements OnInit, OnDestroy {\r\n @Input() public preRender = true;\r\n @Input() public oneTime = false;\r\n @Output() readonly inViewport = new EventEmitter<Partial<IntersectionObserverEntry>>();\r\n\r\n constructor(\r\n private readonly elementRef: ElementRef,\r\n private viewportService: ViewportService,\r\n @Inject(PLATFORM_ID) private platformId: Object,\r\n ) {\r\n }\r\n\r\n public ngOnInit() {\r\n if (isPlatformBrowser(this.platformId)) {\r\n if (this.oneTime) {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(\r\n untilDestroy(this),\r\n filter(entry => entry.intersectionRatio >= 0.5),\r\n take(1),\r\n )\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n } else {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(untilDestroy(this))\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n }\r\n } else {\r\n if (this.preRender) {\r\n this.inViewport.emit({isIntersecting: true, intersectionRatio: 1});\r\n }\r\n }\r\n }\r\n\r\n ngOnDestroy() {\r\n }\r\n}\r\n",
"import {NgModule} from '@angular/core';\r\nimport {CommonModule} from '@angular/common';\r\n\r\nimport * as Components from './components';\r\nimport * as Directives from './directives';\r\nimport * as Services from './services';\r\n\r\n@NgModule({\r\n imports: [CommonModule],\r\n declarations: [Directives.InViewportDirective, Components.InViewportComponent],\r\n providers: [Services.ViewportService],\r\n exports: [Directives.InViewportDirective, Components.InViewportComponent]\r\n})\r\nexport class AitpUtilsModule { }\r\n"
"import {NgModule} from '@angular/core';\r\nimport {CommonModule} from '@angular/common';\r\n\r\nimport * as Components from './components';\r\nimport * as Directives from './directives';\r\nimport * as Services from './services';\r\n\r\n@NgModule({\r\n imports: [CommonModule],\r\n declarations: [Directives.InViewportDirective, Components.InViewportComponent],\r\n providers: [Services.ViewportService],\r\n exports: [Directives.InViewportDirective, Components.InViewportComponent]\r\n})\r\nexport class AitpUtilsModule { }\r\n"