mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
chore: Add support for using injectionTokens in global overrides
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
3532fc1dab
commit
6ae078c91d
4 files changed
+33
-19
No files matched your search
@@ -2,17 +2,30 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { Injectable, Instantiate } from "@ogre-tools/injectable";
|
||||
import type { Injectable, InjectionToken, Instantiate } from "@ogre-tools/injectable";
|
||||
|
||||
export interface GlobalOverride<Instance, Param> {
|
||||
injectable: Injectable<Instance, unknown, Param>;
|
||||
overridingInstantiate: Instantiate<Instance, Param>;
|
||||
export type GlobalOverride<
|
||||
InjectionInstance extends InjectionTokenInstance,
|
||||
InjectionTokenInstance,
|
||||
InstantiationParam,
|
||||
> = ReturnType<typeof getGlobalOverride<InjectionInstance, InjectionTokenInstance, InstantiationParam>>;
|
||||
|
||||
export function getGlobalOverride<
|
||||
InjectionInstance extends InjectionTokenInstance,
|
||||
InjectionTokenInstance,
|
||||
InstantiationParam,
|
||||
>(
|
||||
injectable:
|
||||
| InjectionToken<InjectionInstance, InstantiationParam>
|
||||
| Injectable<
|
||||
InjectionInstance,
|
||||
InjectionTokenInstance,
|
||||
InstantiationParam
|
||||
>,
|
||||
overridingInstantiate: Instantiate<InjectionInstance, InstantiationParam>,
|
||||
) {
|
||||
return {
|
||||
injectable,
|
||||
overridingInstantiate,
|
||||
};
|
||||
}
|
||||
|
||||
export const getGlobalOverride = <Instance, Param>(
|
||||
injectable: Injectable<Instance, unknown, Param>,
|
||||
overridingInstantiate: (typeof injectable)["instantiate"],
|
||||
) => ({
|
||||
injectable,
|
||||
overridingInstantiate,
|
||||
});
|
||||
Reference in new issue
Block a user