-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(primeng/p-tabview): show the `forward' button when necessary
Fixes #11684.
- Loading branch information
Showing
4 changed files
with
108 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Injectable, OnDestroy } from '@angular/core'; | ||
import { Subject } from 'rxjs'; | ||
|
||
/** | ||
* Observable abstraction over ngOnDestroy to use with takeUntil | ||
* @example | ||
*@Component({ | ||
* selector: 'app-example', | ||
* templateUrl: './example.component.html', | ||
* styleUrls: [ './example.component.scss' ], | ||
* providers: [ OnDestroyService ] <=== add to the element providers section | ||
*}) | ||
*export class ExampleComponent implements OnInit, OnDestroy { | ||
* private stream$ = interval(200); | ||
* | ||
* constructor(@Self() private readonly destroy$: OnDestroyService) { <=== Inject, using @Self() | ||
* } | ||
* | ||
* public ngOnInit(): void { | ||
* this.stream$.pipe( | ||
* map((i: number) => i * 2), | ||
* takeUntil(this.destroy$) <=== Use in takeUntil() operator | ||
* ).subscribe(); | ||
* } | ||
*} | ||
*/ | ||
@Injectable() | ||
export class OnDestroyService extends Subject<null> implements OnDestroy { | ||
public ngOnDestroy(): void { | ||
this.next(null); | ||
this.complete(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { NgZone } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
|
||
/** | ||
* RxJs operator, that run subscription function outside NgZone (This operator should be first in the pipe() method | ||
* | ||
* @param {NgZone} zone - injected ngZone reference | ||
* | ||
* @returns {Observable<T>} Input Observable | ||
* | ||
* @example | ||
* fromEvent<MouseEvent>(this.elementRef.nativeElement, 'click') | ||
* .pipe( | ||
* outsideZone(this.zone), | ||
* ...other operators, | ||
* takeUntil(this.destroy$) | ||
* ) | ||
*/ | ||
export function outsideZone<T>(zone: NgZone): (source: Observable<T>) => Observable<T> { | ||
return (source) => new Observable((subscriber) => zone.runOutsideAngular(() => source.subscribe(subscriber))); | ||
} |