mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
improve CatalogPusher.init
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
0d2cf84115
commit
63c981c368
@ -1,5 +1,5 @@
|
|||||||
import { autorun, toJS } from "mobx";
|
import { autorun, toJS } from "mobx";
|
||||||
import { broadcastMessage, subscribeToBroadcast } from "../common/ipc";
|
import { broadcastMessage, subscribeToBroadcast, unsubscribeFromBroadcast } from "../common/ipc";
|
||||||
import { CatalogEntityRegistry} from "../common/catalog-entity-registry";
|
import { CatalogEntityRegistry} from "../common/catalog-entity-registry";
|
||||||
import "../common/catalog-entities/kubernetes-cluster";
|
import "../common/catalog-entities/kubernetes-cluster";
|
||||||
|
|
||||||
@ -8,16 +8,22 @@ export class CatalogPusher {
|
|||||||
new CatalogPusher(catalog).init();
|
new CatalogPusher(catalog).init();
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private catalog: CatalogEntityRegistry) {}
|
private constructor(private catalog: CatalogEntityRegistry) {}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
autorun(() => {
|
const disposers: { (): void; }[] = [];
|
||||||
|
|
||||||
|
disposers.push(autorun(() => {
|
||||||
|
this.broadcast();
|
||||||
|
}));
|
||||||
|
|
||||||
|
const listener = subscribeToBroadcast("catalog:broadcast", () => {
|
||||||
this.broadcast();
|
this.broadcast();
|
||||||
});
|
});
|
||||||
|
|
||||||
subscribeToBroadcast("catalog:broadcast", () => {
|
disposers.push(() => unsubscribeFromBroadcast("catalog:broadcast", listener));
|
||||||
this.broadcast();
|
|
||||||
});
|
return disposers;
|
||||||
}
|
}
|
||||||
|
|
||||||
broadcast() {
|
broadcast() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user