mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
28 lines
722 B
TypeScript
28 lines
722 B
TypeScript
import { autorun, toJS } from "mobx";
|
||
import { broadcastMessage, subscribeToBroadcast } from "../common/ipc";
|
||
import { CatalogEntityRegistry} from "../common/catalog-entity-registry";
|
||
import "../common/catalog-entities/kubernetes-cluster";
|
||
|
||
export class CatalogPusher {
|
||
static init(catalog: CatalogEntityRegistry) {
|
||
new CatalogPusher(catalog).init();
|
||
}
|
||
|
||
constructor(private catalog: CatalogEntityRegistry) {}
|
||
|
||
init() {
|
||
autorun(() => {
|
||
this.broadcast();
|
||
});
|
||
|
||
subscribeToBroadcast("catalog:broadcast", () => {
|
||
this.broadcast();
|
||
});
|
||
}
|
||
|
||
broadcast() {
|
||
console.log("BROADCAST");
|
||
broadcastMessage("catalog:items", toJS(this.catalog.items, { recurseEverything: true }));
|
||
}
|
||
}
|