(FuseNavigation) Merge the subscriptions

(FuseNavigationDocs) Updated the docs
This commit is contained in:
sercan 2018-10-08 19:01:49 +03:00
parent ab7bd882a0
commit 8961d75241
6 changed files with 53 additions and 111 deletions

View File

@ -1,14 +1,14 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit, ViewEncapsulation } from '@angular/core'; 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 { takeUntil } from 'rxjs/operators';
import { FuseNavigationService } from '@fuse/components/navigation/navigation.service'; import { FuseNavigationService } from '@fuse/components/navigation/navigation.service';
@Component({ @Component({
selector : 'fuse-navigation', selector : 'fuse-navigation',
templateUrl : './navigation.component.html', templateUrl : './navigation.component.html',
styleUrls : ['./navigation.component.scss'], styleUrls : ['./navigation.component.scss'],
encapsulation: ViewEncapsulation.None, encapsulation : ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush changeDetection: ChangeDetectionStrategy.OnPush
}) })
export class FuseNavigationComponent implements OnInit export class FuseNavigationComponent implements OnInit
@ -60,31 +60,16 @@ export class FuseNavigationComponent implements OnInit
this._changeDetectorRef.markForCheck(); this._changeDetectorRef.markForCheck();
}); });
// Subscribe to navigation item additions // Subscribe to navigation item
this._fuseNavigationService.onNavigationItemAdded merge(
.pipe(takeUntil(this._unsubscribeAll)) this._fuseNavigationService.onNavigationItemAdded,
.subscribe(() => { this._fuseNavigationService.onNavigationItemUpdated,
this._fuseNavigationService.onNavigationItemRemoved
).pipe(takeUntil(this._unsubscribeAll))
.subscribe(() => {
// Mark for check // Mark for check
this._changeDetectorRef.markForCheck(); 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();
});
} }
} }

View File

@ -1,6 +1,6 @@
import { ChangeDetectorRef, Component, HostBinding, Input, OnDestroy, OnInit } from '@angular/core'; import { ChangeDetectorRef, Component, HostBinding, Input, OnDestroy, OnInit } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router'; import { NavigationEnd, Router } from '@angular/router';
import { Subject } from 'rxjs'; import { merge, Subject } from 'rxjs';
import { filter, takeUntil } from 'rxjs/operators'; import { filter, takeUntil } from 'rxjs/operators';
import { FuseNavigationItem } from '@fuse/types'; import { FuseNavigationItem } from '@fuse/types';
@ -114,32 +114,17 @@ export class FuseNavVerticalCollapsableComponent implements OnInit, OnDestroy
this.collapse(); this.collapse();
} }
// Subscribe to navigation item additions // Subscribe to navigation item
this._fuseNavigationService.onNavigationItemAdded merge(
.pipe(takeUntil(this._unsubscribeAll)) this._fuseNavigationService.onNavigationItemAdded,
.subscribe(() => { this._fuseNavigationService.onNavigationItemUpdated,
this._fuseNavigationService.onNavigationItemRemoved
).pipe(takeUntil(this._unsubscribeAll))
.subscribe(() => {
// Mark for check // Mark for check
this._changeDetectorRef.markForCheck(); 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();
});
} }
/** /**

View File

@ -1,5 +1,5 @@
import { ChangeDetectorRef, Component, HostBinding, Input, OnDestroy, OnInit } from '@angular/core'; 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 { takeUntil } from 'rxjs/operators';
import { FuseNavigationItem } from '@fuse/types'; import { FuseNavigationItem } from '@fuse/types';
@ -48,32 +48,17 @@ export class FuseNavVerticalGroupComponent implements OnInit, OnDestroy
*/ */
ngOnInit(): void ngOnInit(): void
{ {
// Subscribe to navigation item additions // Subscribe to navigation item
this._fuseNavigationService.onNavigationItemAdded merge(
.pipe(takeUntil(this._unsubscribeAll)) this._fuseNavigationService.onNavigationItemAdded,
.subscribe(() => { this._fuseNavigationService.onNavigationItemUpdated,
this._fuseNavigationService.onNavigationItemRemoved
).pipe(takeUntil(this._unsubscribeAll))
.subscribe(() => {
// Mark for check // Mark for check
this._changeDetectorRef.markForCheck(); 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();
});
} }
/** /**

View File

@ -1,5 +1,5 @@
import { ChangeDetectorRef, Component, HostBinding, Input, OnDestroy, OnInit } from '@angular/core'; 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 { takeUntil } from 'rxjs/operators';
import { FuseNavigationItem } from '@fuse/types'; import { FuseNavigationItem } from '@fuse/types';
@ -48,32 +48,17 @@ export class FuseNavVerticalItemComponent implements OnInit, OnDestroy
*/ */
ngOnInit(): void ngOnInit(): void
{ {
// Subscribe to navigation item additions // Subscribe to navigation item
this._fuseNavigationService.onNavigationItemAdded merge(
.pipe(takeUntil(this._unsubscribeAll)) this._fuseNavigationService.onNavigationItemAdded,
.subscribe(() => { this._fuseNavigationService.onNavigationItemUpdated,
this._fuseNavigationService.onNavigationItemRemoved
).pipe(takeUntil(this._unsubscribeAll))
.subscribe(() => {
// Mark for check // Mark for check
this._changeDetectorRef.markForCheck(); 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();
});
} }
/** /**

View File

@ -216,7 +216,7 @@
this._fuseNavigationService.updateNavigationItem('mail', { this._fuseNavigationService.updateNavigationItem('mail', {
badge: { badge: {
title: 35 title: 35
} }
}); });
} }
</textarea> </textarea>

View File

@ -47,8 +47,10 @@ export class DocsComponentsNavigationComponent
updateMailBadge(): void updateMailBadge(): void
{ {
// Update the badge title // Update the badge title
this._fuseNavigationService.updateNavigationItem('02001', { this._fuseNavigationService.updateNavigationItem('mail', {
title: 'Transactionssss' badge: {
title: 35
}
}); });
} }