All files / app/codeCharta/state/effects/linkColorMetricToHeightMetric linkColorMetricToHeightMetric.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 5x 3x        
import { Injectable } from "@angular/core"
import { createEffect } from "@ngrx/effects"
import { Store } from "@ngrx/store"
import { combineLatest, filter, map } from "rxjs"
import { CcState } from "../../../codeCharta.model"
import { isColorMetricLinkedToHeightMetricSelector } from "../../store/appSettings/isHeightAndColorMetricLinked/isColorMetricLinkedToHeightMetric.selector"
 
import { setColorMetric } from "../../store/dynamicSettings/colorMetric/colorMetric.actions"
import { heightMetricSelector } from "../../store/dynamicSettings/heightMetric/heightMetric.selector"
 
@Injectable()
export class LinkColorMetricToHeightMetricEffect {
    constructor(private store: Store<CcState>) {}
 
    linkHeightAndColorMetric$ = createEffect(() =>
        combineLatest([this.store.select(heightMetricSelector), this.store.select(isColorMetricLinkedToHeightMetricSelector)]).pipe(
            filter(([, isColorMetricLinkedToHeightMetric]) => isColorMetricLinkedToHeightMetric),
            map(([heightMetric]) => setColorMetric({ value: heightMetric }))
        )
    )
}