mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Consolidate channel abstraction types
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
08420fd0c2
commit
37d6bfe85e
@ -3,7 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||||
import type { Channel } from "./channel-injection-token";
|
import type { Channel } from "./channel";
|
||||||
|
|
||||||
export interface ChannelListener<TChannel extends Channel<unknown>> {
|
export interface ChannelListener<TChannel extends Channel<unknown>> {
|
||||||
channel: TChannel;
|
channel: TChannel;
|
||||||
|
|||||||
@ -11,8 +11,7 @@ import { sendToAgnosticChannelInjectionToken } from "./send-to-agnostic-channel-
|
|||||||
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||||
import { channelListenerInjectionToken } from "./channel-listener-injection-token";
|
import { channelListenerInjectionToken } from "./channel-listener-injection-token";
|
||||||
import createLensWindowInjectable from "../../main/start-main-application/lens-window/application-window/create-lens-window.injectable";
|
import createLensWindowInjectable from "../../main/start-main-application/lens-window/application-window/create-lens-window.injectable";
|
||||||
import type { Channel } from "./channel-injection-token";
|
import type { Channel } from "./channel";
|
||||||
import { channelInjectionToken } from "./channel-injection-token";
|
|
||||||
|
|
||||||
type TestChannel = Channel<string>;
|
type TestChannel = Channel<string>;
|
||||||
|
|
||||||
@ -158,8 +157,6 @@ const testChannelInjectable = getInjectable({
|
|||||||
id: channelId,
|
id: channelId,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
injectionToken: channelInjectionToken,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const createTestWindow = (di: DiContainer, id: string) => {
|
const createTestWindow = (di: DiContainer, id: string) => {
|
||||||
|
|||||||
@ -2,13 +2,8 @@
|
|||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
|
||||||
|
|
||||||
export interface Channel<TInstance> {
|
export interface Channel<TInstance> {
|
||||||
id: string;
|
id: string;
|
||||||
_template?: TInstance;
|
_template?: TInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const channelInjectionToken = getInjectionToken<Channel<unknown>>({
|
|
||||||
id: "channel",
|
|
||||||
});
|
|
||||||
@ -3,7 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||||
import type { Channel } from "./channel-injection-token";
|
import type { Channel } from "./channel";
|
||||||
|
|
||||||
export type EnlistChannelListener = <TChannel extends Channel<unknown>>(
|
export type EnlistChannelListener = <TChannel extends Channel<unknown>>(
|
||||||
channel: TChannel,
|
channel: TChannel,
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||||
import type { Channel } from "./channel-injection-token";
|
import type { Channel } from "./channel";
|
||||||
|
|
||||||
export type SendToAgnosticChannel = <TChannel extends Channel<unknown>>(
|
export type SendToAgnosticChannel = <TChannel extends Channel<unknown>>(
|
||||||
channel: TChannel,
|
channel: TChannel,
|
||||||
|
|||||||
@ -2,6 +2,10 @@
|
|||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Switch to using newer version of Channel abstraction
|
||||||
|
*/
|
||||||
export interface Channel<TInstance> {
|
export interface Channel<TInstance> {
|
||||||
name: string;
|
name: string;
|
||||||
_template: TInstance;
|
_template: TInstance;
|
||||||
|
|||||||
@ -4,6 +4,9 @@
|
|||||||
*/
|
*/
|
||||||
import type { Channel } from "../channel";
|
import type { Channel } from "../channel";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Switch to using newer version of Channel abstraction
|
||||||
|
*/
|
||||||
export const createChannel = <Message>(name: string): Channel<Message> => ({
|
export const createChannel = <Message>(name: string): Channel<Message> => ({
|
||||||
name,
|
name,
|
||||||
_template: null as never,
|
_template: null as never,
|
||||||
|
|||||||
@ -3,8 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import type { Channel } from "../channel/channel-injection-token";
|
import type { Channel } from "../channel/channel";
|
||||||
import { channelInjectionToken } from "../channel/channel-injection-token";
|
|
||||||
|
|
||||||
export type SyncBoxChannel = Channel<{ id: string; value: unknown }>;
|
export type SyncBoxChannel = Channel<{ id: string; value: unknown }>;
|
||||||
|
|
||||||
@ -14,8 +13,6 @@ const syncBoxChannelInjectable = getInjectable({
|
|||||||
instantiate: (): SyncBoxChannel => ({
|
instantiate: (): SyncBoxChannel => ({
|
||||||
id: "sync-box-channel",
|
id: "sync-box-channel",
|
||||||
}),
|
}),
|
||||||
|
|
||||||
injectionToken: channelInjectionToken,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default syncBoxChannelInjectable;
|
export default syncBoxChannelInjectable;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user