mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
30 lines
971 B
TypeScript
30 lines
971 B
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 powerMonitorInjectable from "../features/power-monitor.injectable";
|
|
import exitAppInjectable from "../features/exit-app.injectable";
|
|
import { whenApplicationIsLoadingInjectionToken } from "../../start-main-application/when-application-is-loading/when-application-is-loading-injection-token";
|
|
|
|
const setupDeviceShutdownInjectable = getInjectable({
|
|
id: "setup-device-shutdown",
|
|
|
|
instantiate: (di) => {
|
|
const powerMonitor = di.inject(powerMonitorInjectable);
|
|
const exitApp = di.inject(exitAppInjectable);
|
|
|
|
return {
|
|
run: () => {
|
|
powerMonitor.on("shutdown", async () => {
|
|
exitApp();
|
|
});
|
|
},
|
|
};
|
|
},
|
|
|
|
injectionToken: whenApplicationIsLoadingInjectionToken,
|
|
});
|
|
|
|
export default setupDeviceShutdownInjectable;
|