mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
store subscribing refactoring -- part 2
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
1 parent
3e005fc611
commit
1f4599ee50
7 files changed
+54
-45
No files matched your search
@@ -24,12 +24,12 @@ export class ClusterOverview extends React.Component {
|
||||
getHostedCluster().available && clusterOverviewStore.loadMetrics();
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
componentDidMount() {
|
||||
this.metricPoller.start(true);
|
||||
|
||||
disposeOnUnmount(this, [
|
||||
await kubeWatchApi.subscribeStores([nodesStore, podsStore, eventStore], {
|
||||
autoLoad: true,
|
||||
kubeWatchApi.subscribeStores([nodesStore, podsStore, eventStore], {
|
||||
preload: true,
|
||||
}),
|
||||
reaction(
|
||||
() => clusterOverviewStore.metricNodeRole, // Toggle Master/Worker node switcher
|
||||
|
||||
@@ -9,6 +9,7 @@ import { Icon } from "../icon";
|
||||
import { namespaceStore } from "./namespace.store";
|
||||
import { FilterIcon } from "../item-object-list/filter-icon";
|
||||
import { FilterType } from "../item-object-list/page-filters.store";
|
||||
import { kubeWatchApi } from "../../api/kube-watch-api";
|
||||
|
||||
interface Props extends SelectProps {
|
||||
showIcons?: boolean;
|
||||
@@ -29,12 +30,11 @@ const defaultProps: Partial<Props> = {
|
||||
export class NamespaceSelect extends React.Component<Props> {
|
||||
static defaultProps = defaultProps as object;
|
||||
|
||||
async componentDidMount() {
|
||||
if (!namespaceStore.isLoaded) {
|
||||
await namespaceStore.loadAll();
|
||||
}
|
||||
componentDidMount() {
|
||||
disposeOnUnmount(this, [
|
||||
await namespaceStore.subscribe(),
|
||||
kubeWatchApi.subscribeStores([namespaceStore], {
|
||||
preload: !namespaceStore.isLoaded,
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,18 +12,18 @@ import { ServicePortComponent } from "./service-port-component";
|
||||
import { endpointStore } from "../+network-endpoints/endpoints.store";
|
||||
import { ServiceDetailsEndpoint } from "./service-details-endpoint";
|
||||
import { kubeObjectDetailRegistry } from "../../api/kube-object-detail-registry";
|
||||
import { kubeWatchApi } from "../../api/kube-watch-api";
|
||||
|
||||
interface Props extends KubeObjectDetailsProps<Service> {
|
||||
}
|
||||
|
||||
@observer
|
||||
export class ServiceDetails extends React.Component<Props> {
|
||||
async componentDidMount() {
|
||||
if (!endpointStore.isLoaded) {
|
||||
endpointStore.loadAll();
|
||||
}
|
||||
componentDidMount() {
|
||||
disposeOnUnmount(this, [
|
||||
await endpointStore.subscribe(),
|
||||
kubeWatchApi.subscribeStores([endpointStore], {
|
||||
preload: !endpointStore.isLoaded,
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,13 +26,14 @@ export class WorkloadsOverview extends React.Component<Props> {
|
||||
@observable isLoading = false;
|
||||
@observable isUnmounting = false;
|
||||
|
||||
async componentDidMount() {
|
||||
componentDidMount() {
|
||||
disposeOnUnmount(this, [
|
||||
await kubeWatchApi.subscribeStores([
|
||||
podsStore, deploymentStore, daemonSetStore,
|
||||
statefulSetStore, replicaSetStore,
|
||||
kubeWatchApi.subscribeStores([
|
||||
podsStore, deploymentStore, daemonSetStore, statefulSetStore, replicaSetStore,
|
||||
jobStore, cronJobStore, eventStore,
|
||||
])
|
||||
], {
|
||||
preload: true,
|
||||
}),
|
||||
]);
|
||||
|
||||
// fixme: reload stores
|
||||
|
||||
@@ -76,17 +76,14 @@ export class App extends React.Component {
|
||||
whatInput.ask(); // Start to monitor user input device
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
const cluster = getHostedCluster();
|
||||
|
||||
componentDidMount() {
|
||||
disposeOnUnmount(this, [
|
||||
await kubeWatchApi.subscribeStores([podsStore, nodesStore, eventStore], {
|
||||
autoLoad: true,
|
||||
waitUntilLoaded: true,
|
||||
kubeWatchApi.subscribeStores([podsStore, nodesStore, eventStore], {
|
||||
preload: true,
|
||||
}),
|
||||
|
||||
reaction(() => this.warningsCount, (count) => {
|
||||
broadcastMessage(`cluster-warning-event-count:${cluster.id}`, count);
|
||||
broadcastMessage(`cluster-warning-event-count:${getHostedCluster().id}`, count);
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -20,12 +20,14 @@ export class KubeObjectListLayout extends React.Component<KubeObjectListLayoutPr
|
||||
return this.props.store.getByPath(kubeSelectedUrlParam.get());
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
const { store, dependentStores } = this.props;
|
||||
componentDidMount() {
|
||||
const { store, dependentStores = [] } = this.props;
|
||||
const stores = Array.from(new Set([store, ...dependentStores]));
|
||||
|
||||
disposeOnUnmount(this, [
|
||||
await kubeWatchApi.subscribeStores(stores)
|
||||
kubeWatchApi.subscribeStores(stores, {
|
||||
preload: true
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user