Skip to content

Commit

Permalink
Add takeuntildestoyed
Browse files Browse the repository at this point in the history
  • Loading branch information
HarelM committed Jun 13, 2024
1 parent a362e34 commit 89c8e4d
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, AfterViewInit, ViewEncapsulation } from "@angular/core";
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
import { MapComponent } from "@maplibre/ngx-maplibre-gl";
import { MapLayerMouseEvent } from "maplibre-gl";
import { Store } from "@ngxs/store";
Expand Down Expand Up @@ -43,10 +44,8 @@ export class RoutesComponent extends BaseMapComponent implements AfterViewInit {

public routePointPopupData: RoutePointViewData;
public nonEditRoutePointPopupData: { latlng: LatLngAlt; wazeAddress: string; routeId: string};

public editingRouteGeoJson: GeoJSON.FeatureCollection<GeoJSON.LineString | GeoJSON.Point>;
public routesGeoJson: GeoJSON.FeatureCollection<GeoJSON.LineString | GeoJSON.Point>;

public routes: Immutable<RouteData[]>;

constructor(resources: ResourcesService,
Expand All @@ -67,10 +66,10 @@ export class RoutesComponent extends BaseMapComponent implements AfterViewInit {
features: []
};
this.routes = [];
this.routeEditRouteInteraction.onRoutePointClick.subscribe(this.handleRoutePointClick);
this.store.select((state: ApplicationState) => state.routes.present).subscribe(routes => this.handleRoutesChanges(routes));
this.store.select((state: ApplicationState) => state.routeEditingState.selectedRouteId).subscribe(() => this.handleRoutesChanges(this.routes));
this.store.select((state: ApplicationState) => state.recordedRouteState.isAddingPoi).subscribe(() => this.setInteractionAccordingToState());
this.routeEditRouteInteraction.onRoutePointClick.pipe(takeUntilDestroyed()).subscribe(this.handleRoutePointClick);
this.store.select((state: ApplicationState) => state.routes.present).pipe(takeUntilDestroyed()).subscribe(routes => this.handleRoutesChanges(routes));
this.store.select((state: ApplicationState) => state.routeEditingState.selectedRouteId).pipe(takeUntilDestroyed()).subscribe(() => this.handleRoutesChanges(this.routes));
this.store.select((state: ApplicationState) => state.recordedRouteState.isAddingPoi).pipe(takeUntilDestroyed()).subscribe(() => this.setInteractionAccordingToState());
}

private handleRoutesChanges(routes: Immutable<RouteData[]>) {
Expand Down

0 comments on commit 89c8e4d

Please sign in to comment.