1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/main/catalog-pusher.ts
Jari Kolehmainen 4ac0c7c899 hotbar store
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
2021-03-31 14:42:46 +03:00

28 lines
722 B
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 }));
}
}