mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Remove global version of appEventBus (#6096)
* Remove global version of appEventBus Signed-off-by: Sebastian Malton <sebastian@malton.name> * Introduce a temporary but better shape of ExecFileInjectable error Signed-off-by: Sebastian Malton <sebastian@malton.name> Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
ba349e8b8d
commit
900f02fd8c
53 files changed
+330
-283
No files matched your search
@@ -1,8 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getGlobalOverride } from "../test-utils/get-global-override";
|
||||
import emitEventInjectable from "./emit-event.injectable";
|
||||
|
||||
export default getGlobalOverride(emitEventInjectable, () => () => {});
|
||||
@@ -3,12 +3,12 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { appEventBus } from "./event-bus";
|
||||
import { EventEmitter } from "../event-emitter";
|
||||
import type { AppEvent } from "./event-bus";
|
||||
|
||||
const appEventBusInjectable = getInjectable({
|
||||
id: "app-event-bus",
|
||||
instantiate: () => appEventBus,
|
||||
causesSideEffects: true,
|
||||
instantiate: () => new EventEmitter<[AppEvent]>,
|
||||
decorable: false,
|
||||
});
|
||||
|
||||
|
||||
@@ -4,11 +4,18 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import appEventBusInjectable from "./app-event-bus.injectable";
|
||||
import type { AppEvent } from "./event-bus";
|
||||
|
||||
const emitEventInjectable = getInjectable({
|
||||
id: "emit-event",
|
||||
instantiate: (di) => di.inject(appEventBusInjectable).emit,
|
||||
export type EmitAppEvent = (event: AppEvent) => void;
|
||||
|
||||
const emitAppEventInjectable = getInjectable({
|
||||
id: "emit-app-event",
|
||||
instantiate: (di): EmitAppEvent => {
|
||||
const bus = di.inject(appEventBusInjectable);
|
||||
|
||||
return (event) => bus.emit(event);
|
||||
},
|
||||
decorable: false,
|
||||
});
|
||||
|
||||
export default emitEventInjectable;
|
||||
export default emitAppEventInjectable;
|
||||
@@ -3,13 +3,12 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { EventEmitter } from "../event-emitter";
|
||||
|
||||
/**
|
||||
* Data for telemetry
|
||||
*/
|
||||
export interface AppEvent {
|
||||
name: string;
|
||||
action: string;
|
||||
destination?: string;
|
||||
params?: Record<string, any>;
|
||||
}
|
||||
|
||||
export const appEventBus = new EventEmitter<[AppEvent]>();
|
||||
Reference in new issue
Block a user