I want to know how to unsubscribe from this subscription?
inventory.component.ts
constructor(
    private terminalService: TerminalService,
    private router: Router,
    private inventoryFilterService: InventoryFilterService
) {
    this.inventoryFilterService.listen().subscribe(() => {
        this.checkState();
    });
}
my problem is, that when i leave the component where i needed this service and re-enter it (the component), every mouse-click into my header-component (where the filter-button is) gets fired twice. I think this happens because i didn't unsubscribe from the service subscription but i also can't figure out how to do this.
inventory-filter.service.ts
@Injectable({
    providedIn: 'root',
})
export class InventoryFilterService {
    constructor() { }
    private _listners = new Subject<any>();
    listen(): Observable<any> {
        return this._listners.asObservable();
    }
    filter() {
        this._listners.next();
    }
}
header-inventory.component.ts
import { Component, OnInit, Output } from '@angular/core';
import { UserRightsService } from 'src/app/services/user/user-rights.service';
import { EventEmitter } from 'events';
import { InventoryFilterService } from 'src/app/services/inventory/inventory-filter.service';
@Component({
    selector: 'app-header-inventory',
    templateUrl: './header-inventory.component.html',
    styleUrls: ['./header-inventory.component.css'],
    providers: [UserRightsService],
})
export class HeaderInventoryComponent implements OnInit {
    @Output() onFilter: EventEmitter = new EventEmitter();
    canAddInventoryItem: Boolean;
    internalOnly: Boolean;
    constructor(
        private userRightsService: UserRightsService,
        private inventoryFilterService: InventoryFilterService,
    ) { }
    ngOnInit() {
    }
    showInternalTerminals(): void {
        this.inventoryFilterService.filter();
        if (localStorage.getItem('onlyInternal') === 'false') {
            this.internalOnly = true;
        } else {
            this.internalOnly = false;
        }
    }
}
inventory.component.ts
import { Component, OnInit, ViewChild, OnDestroy } from '@angular/core';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { TerminalService } from 'src/app/services/terminal/terminal.service';
import { Router } from '@angular/router';
import { InventoryFilterService } from 'src/app/services/inventory/inventory-filter.service';
@Component({
    selector: 'app-inventory',
    templateUrl: './inventory.component.html',
    styleUrls: ['./inventory.component.css'],
})
export class InventoryComponent implements OnInit {
    constructor(
        private terminalService: TerminalService,
        private router: Router,
        private inventoryFilterService: InventoryFilterService
    ) {
        this.inventoryFilterService.listen().subscribe(() => {
            this.checkState();
        });
    }
....
 
     
    