mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-02-20 17:52:46 +00:00
Merge pull request #695 from GNS3/One-subscription-instead-of-many-subscriptions
One subscription instead of many subscriptions
This commit is contained in:
commit
adadf886ab
@ -110,7 +110,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
@ViewChild(D3MapComponent, {static: false}) mapChild: D3MapComponent;
|
||||
@ViewChild(ProjectMapMenuComponent, {static: false}) projectMapMenuComponent: ProjectMapMenuComponent;
|
||||
|
||||
private subscriptions: Subscription[] = [];
|
||||
private projectMapSubscription: Subscription = new Subscription();
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
@ -213,22 +213,22 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
);
|
||||
});
|
||||
|
||||
this.subscriptions.push(routeSub);
|
||||
this.projectMapSubscription.add(routeSub);
|
||||
|
||||
this.subscriptions.push(
|
||||
this.projectMapSubscription.add(
|
||||
this.mapSettingsService.mapRenderedEmitter.subscribe((value: boolean) => {
|
||||
if (this.scrollEnabled) this.centerCanvas();
|
||||
})
|
||||
);
|
||||
|
||||
this.subscriptions.push(
|
||||
this.projectMapSubscription.add(
|
||||
this.drawingsDataSource.changes.subscribe((drawings: Drawing[]) => {
|
||||
this.drawings = drawings;
|
||||
this.mapChangeDetectorRef.detectChanges();
|
||||
})
|
||||
);
|
||||
|
||||
this.subscriptions.push(
|
||||
this.projectMapSubscription.add(
|
||||
this.nodesDataSource.changes.subscribe((nodes: Node[]) => {
|
||||
if (!this.server) return;
|
||||
nodes.forEach((node: Node) => {
|
||||
@ -240,21 +240,21 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
})
|
||||
);
|
||||
|
||||
this.subscriptions.push(
|
||||
this.projectMapSubscription.add(
|
||||
this.linksDataSource.changes.subscribe((links: Link[]) => {
|
||||
this.links = links;
|
||||
this.mapChangeDetectorRef.detectChanges();
|
||||
})
|
||||
);
|
||||
|
||||
this.subscriptions.push(this.projectWebServiceHandler.errorNotificationEmitter.subscribe((message) => {
|
||||
this.projectMapSubscription.add(this.projectWebServiceHandler.errorNotificationEmitter.subscribe((message) => {
|
||||
this.showMessage({
|
||||
type: 'error',
|
||||
message: message
|
||||
});
|
||||
}));
|
||||
|
||||
this.subscriptions.push(this.projectWebServiceHandler.warningNotificationEmitter.subscribe((message) => {
|
||||
this.projectMapSubscription.add(this.projectWebServiceHandler.warningNotificationEmitter.subscribe((message) => {
|
||||
this.showMessage({
|
||||
type: 'warning',
|
||||
message: message
|
||||
@ -326,7 +326,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
|
||||
this.progressService.deactivate();
|
||||
});
|
||||
this.subscriptions.push(subscription);
|
||||
this.projectMapSubscription.add(subscription);
|
||||
}
|
||||
|
||||
setUpProjectWS(project: Project) {
|
||||
@ -411,14 +411,14 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
this.contextMenu.openMenuForListOfElements(drawings, nodes, labels, links, event.pageY, event.pageX);
|
||||
});
|
||||
|
||||
this.subscriptions.push(onLinkContextMenu);
|
||||
this.subscriptions.push(onEthernetLinkContextMenu);
|
||||
this.subscriptions.push(onSerialLinkContextMenu);
|
||||
this.subscriptions.push(onNodeContextMenu);
|
||||
this.subscriptions.push(onDrawingContextMenu);
|
||||
this.subscriptions.push(onContextMenu);
|
||||
this.subscriptions.push(onLabelContextMenu);
|
||||
this.subscriptions.push(onInterfaceLabelContextMenu);
|
||||
this.projectMapSubscription.add(onLinkContextMenu);
|
||||
this.projectMapSubscription.add(onEthernetLinkContextMenu);
|
||||
this.projectMapSubscription.add(onSerialLinkContextMenu);
|
||||
this.projectMapSubscription.add(onNodeContextMenu);
|
||||
this.projectMapSubscription.add(onDrawingContextMenu);
|
||||
this.projectMapSubscription.add(onContextMenu);
|
||||
this.projectMapSubscription.add(onLabelContextMenu);
|
||||
this.projectMapSubscription.add(onInterfaceLabelContextMenu);
|
||||
this.mapChangeDetectorRef.detectChanges();
|
||||
}
|
||||
|
||||
@ -833,7 +833,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy {
|
||||
if (this.ws) {
|
||||
if (this.ws.OPEN) this.ws.close();
|
||||
}
|
||||
this.subscriptions.forEach((subscription: Subscription) => subscription.unsubscribe());
|
||||
this.projectMapSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user