From 8961d752413198c00cc0d2a3592155670424d67c Mon Sep 17 00:00:00 2001 From: sercan Date: Mon, 8 Oct 2018 19:01:49 +0300 Subject: [PATCH] (FuseNavigation) Merge the subscriptions (FuseNavigationDocs) Updated the docs --- .../navigation/navigation.component.ts | 45 +++++++------------ .../collapsable/collapsable.component.ts | 37 +++++---------- .../vertical/group/group.component.ts | 37 +++++---------- .../vertical/item/item.component.ts | 37 +++++---------- .../navigation/navigation.component.html | 2 +- .../navigation/navigation.component.ts | 6 ++- 6 files changed, 53 insertions(+), 111 deletions(-) diff --git a/src/@fuse/components/navigation/navigation.component.ts b/src/@fuse/components/navigation/navigation.component.ts index 6e645df6..c7fac5b8 100644 --- a/src/@fuse/components/navigation/navigation.component.ts +++ b/src/@fuse/components/navigation/navigation.component.ts @@ -1,14 +1,14 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit, ViewEncapsulation } from '@angular/core'; -import { Subject } from 'rxjs'; +import { merge, Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { FuseNavigationService } from '@fuse/components/navigation/navigation.service'; @Component({ - selector : 'fuse-navigation', - templateUrl : './navigation.component.html', - styleUrls : ['./navigation.component.scss'], - encapsulation: ViewEncapsulation.None, + selector : 'fuse-navigation', + templateUrl : './navigation.component.html', + styleUrls : ['./navigation.component.scss'], + encapsulation : ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush }) export class FuseNavigationComponent implements OnInit @@ -60,31 +60,16 @@ export class FuseNavigationComponent implements OnInit this._changeDetectorRef.markForCheck(); }); - // Subscribe to navigation item additions - this._fuseNavigationService.onNavigationItemAdded - .pipe(takeUntil(this._unsubscribeAll)) - .subscribe(() => { + // Subscribe to navigation item + merge( + this._fuseNavigationService.onNavigationItemAdded, + this._fuseNavigationService.onNavigationItemUpdated, + this._fuseNavigationService.onNavigationItemRemoved + ).pipe(takeUntil(this._unsubscribeAll)) + .subscribe(() => { - // Mark for check - this._changeDetectorRef.markForCheck(); - }); - - // Subscribe to navigation item updates - this._fuseNavigationService.onNavigationItemUpdated - .pipe(takeUntil(this._unsubscribeAll)) - .subscribe(() => { - - // Mark for check - this._changeDetectorRef.markForCheck(); - }); - - // Subscribe to navigation item removal - this._fuseNavigationService.onNavigationItemRemoved - .pipe(takeUntil(this._unsubscribeAll)) - .subscribe(() => { - - // Mark for check - this._changeDetectorRef.markForCheck(); - }); + // Mark for check + this._changeDetectorRef.markForCheck(); + }); } } diff --git a/src/@fuse/components/navigation/vertical/collapsable/collapsable.component.ts b/src/@fuse/components/navigation/vertical/collapsable/collapsable.component.ts index 67ca4cf6..7e20cd4e 100644 --- a/src/@fuse/components/navigation/vertical/collapsable/collapsable.component.ts +++ b/src/@fuse/components/navigation/vertical/collapsable/collapsable.component.ts @@ -1,6 +1,6 @@ import { ChangeDetectorRef, Component, HostBinding, Input, OnDestroy, OnInit } from '@angular/core'; import { NavigationEnd, Router } from '@angular/router'; -import { Subject } from 'rxjs'; +import { merge, Subject } from 'rxjs'; import { filter, takeUntil } from 'rxjs/operators'; import { FuseNavigationItem } from '@fuse/types'; @@ -114,32 +114,17 @@ export class FuseNavVerticalCollapsableComponent implements OnInit, OnDestroy this.collapse(); } - // Subscribe to navigation item additions - this._fuseNavigationService.onNavigationItemAdded - .pipe(takeUntil(this._unsubscribeAll)) - .subscribe(() => { + // Subscribe to navigation item + merge( + this._fuseNavigationService.onNavigationItemAdded, + this._fuseNavigationService.onNavigationItemUpdated, + this._fuseNavigationService.onNavigationItemRemoved + ).pipe(takeUntil(this._unsubscribeAll)) + .subscribe(() => { - // Mark for check - this._changeDetectorRef.markForCheck(); - }); - - // Subscribe to navigation item updates - this._fuseNavigationService.onNavigationItemUpdated - .pipe(takeUntil(this._unsubscribeAll)) - .subscribe(() => { - - // Mark for check - this._changeDetectorRef.markForCheck(); - }); - - // Subscribe to navigation item removal - this._fuseNavigationService.onNavigationItemRemoved - .pipe(takeUntil(this._unsubscribeAll)) - .subscribe(() => { - - // Mark for check - this._changeDetectorRef.markForCheck(); - }); + // Mark for check + this._changeDetectorRef.markForCheck(); + }); } /** diff --git a/src/@fuse/components/navigation/vertical/group/group.component.ts b/src/@fuse/components/navigation/vertical/group/group.component.ts index 58e5bbca..63a1c403 100644 --- a/src/@fuse/components/navigation/vertical/group/group.component.ts +++ b/src/@fuse/components/navigation/vertical/group/group.component.ts @@ -1,5 +1,5 @@ import { ChangeDetectorRef, Component, HostBinding, Input, OnDestroy, OnInit } from '@angular/core'; -import { Subject } from 'rxjs'; +import { merge, Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { FuseNavigationItem } from '@fuse/types'; @@ -48,32 +48,17 @@ export class FuseNavVerticalGroupComponent implements OnInit, OnDestroy */ ngOnInit(): void { - // Subscribe to navigation item additions - this._fuseNavigationService.onNavigationItemAdded - .pipe(takeUntil(this._unsubscribeAll)) - .subscribe(() => { + // Subscribe to navigation item + merge( + this._fuseNavigationService.onNavigationItemAdded, + this._fuseNavigationService.onNavigationItemUpdated, + this._fuseNavigationService.onNavigationItemRemoved + ).pipe(takeUntil(this._unsubscribeAll)) + .subscribe(() => { - // Mark for check - this._changeDetectorRef.markForCheck(); - }); - - // Subscribe to navigation item updates - this._fuseNavigationService.onNavigationItemUpdated - .pipe(takeUntil(this._unsubscribeAll)) - .subscribe(() => { - - // Mark for check - this._changeDetectorRef.markForCheck(); - }); - - // Subscribe to navigation item removal - this._fuseNavigationService.onNavigationItemRemoved - .pipe(takeUntil(this._unsubscribeAll)) - .subscribe(() => { - - // Mark for check - this._changeDetectorRef.markForCheck(); - }); + // Mark for check + this._changeDetectorRef.markForCheck(); + }); } /** diff --git a/src/@fuse/components/navigation/vertical/item/item.component.ts b/src/@fuse/components/navigation/vertical/item/item.component.ts index b23ecc1c..4de8ccf6 100644 --- a/src/@fuse/components/navigation/vertical/item/item.component.ts +++ b/src/@fuse/components/navigation/vertical/item/item.component.ts @@ -1,5 +1,5 @@ import { ChangeDetectorRef, Component, HostBinding, Input, OnDestroy, OnInit } from '@angular/core'; -import { Subject } from 'rxjs'; +import { merge, Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { FuseNavigationItem } from '@fuse/types'; @@ -48,32 +48,17 @@ export class FuseNavVerticalItemComponent implements OnInit, OnDestroy */ ngOnInit(): void { - // Subscribe to navigation item additions - this._fuseNavigationService.onNavigationItemAdded - .pipe(takeUntil(this._unsubscribeAll)) - .subscribe(() => { + // Subscribe to navigation item + merge( + this._fuseNavigationService.onNavigationItemAdded, + this._fuseNavigationService.onNavigationItemUpdated, + this._fuseNavigationService.onNavigationItemRemoved + ).pipe(takeUntil(this._unsubscribeAll)) + .subscribe(() => { - // Mark for check - this._changeDetectorRef.markForCheck(); - }); - - // Subscribe to navigation item updates - this._fuseNavigationService.onNavigationItemUpdated - .pipe(takeUntil(this._unsubscribeAll)) - .subscribe(() => { - - // Mark for check - this._changeDetectorRef.markForCheck(); - }); - - // Subscribe to navigation item removal - this._fuseNavigationService.onNavigationItemRemoved - .pipe(takeUntil(this._unsubscribeAll)) - .subscribe(() => { - - // Mark for check - this._changeDetectorRef.markForCheck(); - }); + // Mark for check + this._changeDetectorRef.markForCheck(); + }); } /** diff --git a/src/app/main/documentation/components/navigation/navigation.component.html b/src/app/main/documentation/components/navigation/navigation.component.html index af951206..c2ec2203 100644 --- a/src/app/main/documentation/components/navigation/navigation.component.html +++ b/src/app/main/documentation/components/navigation/navigation.component.html @@ -216,7 +216,7 @@ this._fuseNavigationService.updateNavigationItem('mail', { badge: { title: 35 - } + } }); } diff --git a/src/app/main/documentation/components/navigation/navigation.component.ts b/src/app/main/documentation/components/navigation/navigation.component.ts index e661c110..f1821229 100644 --- a/src/app/main/documentation/components/navigation/navigation.component.ts +++ b/src/app/main/documentation/components/navigation/navigation.component.ts @@ -47,8 +47,10 @@ export class DocsComponentsNavigationComponent updateMailBadge(): void { // Update the badge title - this._fuseNavigationService.updateNavigationItem('02001', { - title: 'Transactionssss' + this._fuseNavigationService.updateNavigationItem('mail', { + badge: { + title: 35 + } }); }