Fix memory leak in unit tests (#5597)

This commit is contained in:
Sebastian Malton authored and GitHub committed 2022-06-13 11:00:07 -04:00
1 parent 2eb585e88e
commit 3058bea88f
37 files changed
+1502 -1777

No files matched your search

@@ -0,0 +1,34 @@
/**
* 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 { action } from "mobx";
import { beforeFrameStartsInjectionToken } from "../../../before-frame-starts/before-frame-starts-injection-token";
import ipcRendererInjectable from "../../../utils/channel/ipc-renderer.injectable";
import topBarStateInjectable from "./state.injectable";
// TODO: replace with a SyncBox
const startTopbarStateSyncInjectable = getInjectable({
id: "start-topbar-state-sync",
instantiate: (di) => {
const state = di.inject(topBarStateInjectable);
const ipcRenderer = di.inject(ipcRendererInjectable);
return {
run: () => {
ipcRenderer.on("history:can-go-back", action((event, canGoBack: boolean) => {
state.prevEnabled = canGoBack;
}));
ipcRenderer.on("history:can-go-forward", action((event, canGoForward: boolean) => {
state.nextEnabled = canGoForward;
}));
},
};
},
injectionToken: beforeFrameStartsInjectionToken,
causesSideEffects: true,
});
export default startTopbarStateSyncInjectable;