Skip to content

Commit

Permalink
refactor: utlize onInit
Browse files Browse the repository at this point in the history
as constructor is blocking and should only be used for simple property setting

refs #2318
  • Loading branch information
shaman-apprentice committed Sep 13, 2021
1 parent 65c7f5e commit d121966
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Inject, Input } from "@angular/core"
import { Component, Inject, Input, OnInit } from "@angular/core"
import { Observable } from "rxjs"
import { MapColors } from "../../codeCharta.model"
import { Store } from "../../state/angular-redux/store"
Expand All @@ -10,13 +10,15 @@ import { CodeMapBuilding } from "../codeMap/rendering/codeMapBuilding"
selector: "cc-metric-delta-selected",
template: require("./metricDeltaSelected.component.html")
})
export class MetricDeltaSelectedComponent {
export class MetricDeltaSelectedComponent implements OnInit {
@Input() attributeKey: string

selectedBuilding$: Observable<CodeMapBuilding>
mapColors$: Observable<MapColors>

constructor(@Inject(Store) private store: Store) {
constructor(@Inject(Store) private store: Store) {}

ngOnInit(): void {
this.selectedBuilding$ = this.store.select((state: CcState) => {
const selectedBuildingId = selectedBuildingIdSelector(state)
return state.lookUp.idToBuilding.get(selectedBuildingId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Inject } from "@angular/core"
import { Component, Inject, OnInit } from "@angular/core"
import { Observable } from "rxjs"

import { Store } from "../../state/angular-redux/store"
Expand All @@ -9,10 +9,12 @@ import { sortingOrderAscendingSelector } from "../../state/store/appSettings/sor
selector: "cc-sorting-button",
template: require("./sortingButton.component.html")
})
export class SortingButtonComponent {
export class SortingButtonComponent implements OnInit {
orderAscending$: Observable<boolean>

constructor(@Inject(Store) private store: Store) {
constructor(@Inject(Store) private store: Store) {}

ngOnInit(): void {
this.orderAscending$ = this.store.select(sortingOrderAscendingSelector)
}

Expand Down

0 comments on commit d121966

Please sign in to comment.