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 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 3x 3x 3x 3x 3x 3x 3x 3x 4x 3x 3x 3x 3x 3x 3x 2x 2x | import { Injectable } from "@angular/core"
import { Actions, createEffect, ofType } from "@ngrx/effects"
import { Store } from "@ngrx/store"
import { asyncScheduler, combineLatest, filter, share, tap, throttleTime } from "rxjs"
import { CcState } from "../../../codeCharta.model"
import { CodeMapRenderService } from "../../../ui/codeMap/codeMap.render.service"
import { ThreeRendererService } from "../../../ui/codeMap/threeViewer/threeRenderer.service"
import { UploadFilesService } from "../../../ui/toolBar/uploadFilesButton/uploadFiles.service"
import { accumulatedDataSelector } from "../../selectors/accumulatedData/accumulatedData.selector"
import { actionsRequiringRerender } from "./actionsRequiringRerender"
import { setIsLoadingFile } from "../../store/appSettings/isLoadingFile/isLoadingFile.actions"
import { setIsLoadingMap } from "../../store/appSettings/isLoadingMap/isLoadingMap.actions"
export const maxFPS = 1000 / 60
@Injectable()
export class RenderCodeMapEffect {
constructor(
private store: Store<CcState>,
private actions$: Actions,
private uploadFilesService: UploadFilesService,
private threeRendererService: ThreeRendererService,
private codeMapRenderService: CodeMapRenderService
) {}
private actionsRequiringRender$ = this.actions$.pipe(ofType(...actionsRequiringRerender))
renderCodeMap$ = createEffect(
() =>
combineLatest([this.store.select(accumulatedDataSelector), this.actionsRequiringRender$]).pipe(
filter(([accumulatedData]) => Boolean(accumulatedData.unifiedMapNode)),
throttleTime(maxFPS, asyncScheduler, { leading: false, trailing: true }),
tap(([accumulatedData]) => {
this.codeMapRenderService.render(accumulatedData.unifiedMapNode)
this.codeMapRenderService.scaleMap()
this.threeRendererService.render()
}),
share()
),
{ dispatch: false }
)
removeLoadingIndicatorAfterRender$ = createEffect(
() =>
this.renderCodeMap$.pipe(
filter(() => !this.uploadFilesService.isUploading),
tap(() => {
this.store.dispatch(setIsLoadingFile({ value: false }))
this.store.dispatch(setIsLoadingMap({ value: false }))
})
),
{ dispatch: false }
)
}
|