我需要取消订阅 Ngrx Select

Do i need to unsubscribe from an Ngrx Select

我有一个组件如下,其中有一个按钮在单击时调用 select_property。问题是我不确定在每次点击重新分配 $livevisitors 之前我是否需要以任何方式取消订阅,不确定组件模板中的 $livevisitors | async 是否对我有用。

export class LiveComponent{

    livevisitors$: Observable<LiveVisitor[]>;
    selected_property_id: number = 0;

    constructor(
            private store: Store<AppState>
        ) {

        this.livevisitors$ = this.store.select(selectAllLiveVisitors);

    }

    select_property(id){
        this.selected_property_id = id;

        if (id == 0){
            this.livevisitors$ = this.store.select(selectAllLiveVisitors);
        } else {
            this.livevisitors$ = this.store.select(selectLiveVisitorsByPropertyId, {property_id: id});
        }
    }

async 管道为您订阅和取消订阅。您无需管理手动退订。

来自官方documentation :

当组件被销毁时,异步管道会自动取消订阅以避免潜在的内存泄漏。