Skip to content

Commit 85e4716

Browse files
committed
Fix initializer of instance members that reference identifiers declared in the constructor.
1 parent 7a8b022 commit 85e4716

File tree

3 files changed

+52
-49
lines changed

3 files changed

+52
-49
lines changed

tensorboard/webapp/metrics/views/main_view/empty_tag_match_message_container.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,19 @@ import {getSortedRenderableCardIdsWithMetadata} from './common_selectors';
3636
changeDetection: ChangeDetectionStrategy.OnPush,
3737
})
3838
export class EmptyTagMatchMessageContainer {
39-
constructor(private readonly store: Store<State>) {}
39+
constructor(private readonly store: Store<State>) {
40+
this.pluginTypes$ = this.store.select(getMetricsFilteredPluginTypes);
41+
this.tagFilterRegex$ = this.store.select(getMetricsTagFilter);
42+
this.tagCounts$ = this.store
43+
.select(getSortedRenderableCardIdsWithMetadata)
44+
.pipe(
45+
map((cardList) => {
46+
return new Set(cardList.map(({tag}) => tag)).size;
47+
}),
48+
);
49+
}
4050

41-
readonly pluginTypes$: Observable<Set<PluginType>> = this.store.select(
42-
getMetricsFilteredPluginTypes
43-
);
44-
readonly tagFilterRegex$: Observable<string> =
45-
this.store.select(getMetricsTagFilter);
46-
readonly tagCounts$: Observable<number> = this.store
47-
.select(getSortedRenderableCardIdsWithMetadata)
48-
.pipe(
49-
map((cardList) => {
50-
return new Set(cardList.map(({tag}) => tag)).size;
51-
})
52-
);
51+
readonly pluginTypes$: Observable<Set<PluginType>>;
52+
readonly tagFilterRegex$: Observable<string>;
53+
readonly tagCounts$: Observable<number>;
5354
}

tensorboard/webapp/metrics/views/main_view/main_view_component.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,18 @@ export class MainViewComponent {
6262
@Optional()
6363
@Inject(SHARE_BUTTON_COMPONENT)
6464
readonly customShareButton: Type<Component>
65-
) {}
65+
) {
66+
this.cardObserver = new CardObserver(
67+
this.host.nativeElement,
68+
'600px 0px 600px 0px'
69+
);
70+
}
6671

6772
readonly PluginType = PluginType;
6873

6974
/**
7075
* Load cards that are not yet visible, if they are roughly 1 card row away in
7176
* scroll distance.
7277
*/
73-
readonly cardObserver = new CardObserver(
74-
this.host.nativeElement,
75-
'600px 0px 600px 0px'
76-
);
78+
readonly cardObserver;
7779
}

tensorboard/webapp/metrics/views/main_view/main_view_container.ts

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -51,42 +51,42 @@ import {PluginType} from '../../types';
5151
changeDetection: ChangeDetectionStrategy.OnPush,
5252
})
5353
export class MainViewContainer {
54-
constructor(private readonly store: Store<State>) {}
55-
56-
readonly isSidepaneOpen$: Observable<boolean> = this.store.select(
57-
isMetricsSettingsPaneOpen
58-
);
59-
60-
readonly initialTagsLoading$: Observable<boolean> = this.store
61-
.select(getMetricsTagMetadataLoadState)
62-
.pipe(
63-
// disconnect and don't listen to store if tags are loaded at least once.
64-
takeWhile((loadState) => {
65-
return loadState.lastLoadedTimeInMs === null;
66-
}, true /** inclusive */),
67-
map((loadState) => {
68-
return (
69-
loadState.state === DataLoadState.LOADING &&
70-
loadState.lastLoadedTimeInMs === null
71-
);
72-
})
73-
);
74-
75-
readonly showFilteredView$: Observable<boolean> = this.store
76-
.select(getMetricsTagFilter)
77-
.pipe(
54+
constructor(private readonly store: Store<State>) {
55+
this.isSidepaneOpen$ = this.store.select(isMetricsSettingsPaneOpen);
56+
this.initialTagsLoading$ = this.store
57+
.select(getMetricsTagMetadataLoadState)
58+
.pipe(
59+
// disconnect and don't listen to store if tags are loaded at least once.
60+
takeWhile((loadState) => {
61+
return loadState.lastLoadedTimeInMs === null;
62+
}, true /** inclusive */),
63+
map((loadState) => {
64+
return (
65+
loadState.state === DataLoadState.LOADING &&
66+
loadState.lastLoadedTimeInMs === null
67+
);
68+
}),
69+
);
70+
this.showFilteredView$ = this.store.select(getMetricsTagFilter).pipe(
7871
map((filter) => {
7972
return filter.length > 0;
80-
})
73+
}),
74+
);
75+
this.filteredPluginTypes$ = this.store.select(
76+
getMetricsFilteredPluginTypes,
8177
);
78+
this.isSlideoutMenuOpen$ = this.store.select(isMetricsSlideoutMenuOpen);
79+
}
80+
81+
readonly isSidepaneOpen$: Observable<boolean>;
82+
83+
readonly initialTagsLoading$: Observable<boolean>;
84+
85+
readonly showFilteredView$: Observable<boolean>;
8286

83-
readonly filteredPluginTypes$ = this.store.select(
84-
getMetricsFilteredPluginTypes
85-
);
87+
readonly filteredPluginTypes$;
8688

87-
readonly isSlideoutMenuOpen$: Observable<boolean> = this.store.select(
88-
isMetricsSlideoutMenuOpen
89-
);
89+
readonly isSlideoutMenuOpen$: Observable<boolean>;
9090

9191
onSettingsButtonClicked() {
9292
this.store.dispatch(metricsSettingsPaneToggled());

0 commit comments

Comments
 (0)