All files / app/codeCharta/state/effects/updateEdgePreviews updateEdgePreviews.effect.ts

100% Statements 14/14
100% Branches 0/0
100% Functions 4/4
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 221x 1x 1x 1x 1x 1x 1x       1x 2x   2x 2x   4x 3x        
import { Injectable } from "@angular/core"
import { filter, map, withLatestFrom } from "rxjs"
import { createEffect } from "@ngrx/effects"
import { toggleEdgeMetricVisible } from "../../store/appSettings/isEdgeMetricVisible/isEdgeMetricVisible.actions"
import { isEdgeMetricVisibleSelector } from "../../store/appSettings/isEdgeMetricVisible/isEdgeMetricVisible.selector"
import { edgeMetricSelector } from "../../store/dynamicSettings/edgeMetric/edgeMetric.selector"
import { Store } from "@ngrx/store"
import { CcState } from "../../../codeCharta.model"
 
@Injectable()
export class UpdateEdgePreviewsEffect {
    constructor(private store: Store<CcState>) {}
 
    resetIsEdgeMetricVisible$ = createEffect(() =>
        this.store.select(edgeMetricSelector).pipe(
            withLatestFrom(this.store.select(isEdgeMetricVisibleSelector)),
            filter(([, isEdgeMetricVisible]) => !isEdgeMetricVisible),
            map(() => toggleEdgeMetricVisible())
        )
    )
}