mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
- To help fix issues around injection time Signed-off-by: Sebastian Malton <sebastian@malton.name>
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import { getInjectable } from "@ogre-tools/injectable";
|
|
import { reaction } from "mobx";
|
|
import { currentClusterMessageChannel } from "../../../common/cluster/current-cluster-channel";
|
|
import { sendMessageToChannelInjectionToken } from "../../../common/utils/channel/message-to-channel-injection-token";
|
|
import matchedClusterIdInjectable from "../../navigation/matched-cluster-id.injectable";
|
|
import { evenBeforeMainFrameStartsInjectionToken } from "../tokens";
|
|
|
|
const setupCurrentClusterBroadcastInjectable = getInjectable({
|
|
id: "setup-current-cluster-broadcast",
|
|
instantiate: (di) => ({
|
|
id: "setup-current-cluster-broadcast",
|
|
run: () => {
|
|
const matchedClusterId = di.inject(matchedClusterIdInjectable);
|
|
const sendMessageToChannel = di.inject(sendMessageToChannelInjectionToken);
|
|
|
|
reaction(
|
|
() => matchedClusterId.get(),
|
|
clusterId => sendMessageToChannel(currentClusterMessageChannel, clusterId),
|
|
{
|
|
fireImmediately: true,
|
|
},
|
|
);
|
|
},
|
|
}),
|
|
injectionToken: evenBeforeMainFrameStartsInjectionToken,
|
|
});
|
|
|
|
export default setupCurrentClusterBroadcastInjectable;
|