mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Rename helper function to better communicate intent
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
6dd41c13ba
commit
67da7d7f5b
@ -8,7 +8,7 @@ import emitAppEventInjectable from "../../../../common/app-event-bus/emit-event.
|
|||||||
import type { ClusterModel } from "../../../../common/cluster-types";
|
import type { ClusterModel } from "../../../../common/cluster-types";
|
||||||
import { Cluster } from "../../../../common/cluster/cluster";
|
import { Cluster } from "../../../../common/cluster/cluster";
|
||||||
import clustersStateInjectable from "./state.injectable";
|
import clustersStateInjectable from "./state.injectable";
|
||||||
import { setAndInsert } from "@k8slens/utilities";
|
import { setAndGet } from "@k8slens/utilities";
|
||||||
|
|
||||||
export type AddCluster = (clusterModel: ClusterModel) => Cluster;
|
export type AddCluster = (clusterModel: ClusterModel) => Cluster;
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ const addClusterInjectable = getInjectable({
|
|||||||
return action((clusterModel) => {
|
return action((clusterModel) => {
|
||||||
emitAppEvent({ name: "cluster", action: "add" });
|
emitAppEvent({ name: "cluster", action: "add" });
|
||||||
|
|
||||||
return setAndInsert(clustersState, clusterModel.id, new Cluster(clusterModel));
|
return setAndGet(clustersState, clusterModel.id, new Cluster(clusterModel));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@ -88,7 +88,7 @@ export async function getOrInsertWithAsync<K, V>(map: Map<K, V>, key: K, asyncBu
|
|||||||
/**
|
/**
|
||||||
* Insert `val` into `map` under `key` and then get the value back
|
* Insert `val` into `map` under `key` and then get the value back
|
||||||
*/
|
*/
|
||||||
export function setAndInsert<K, V>(map: Map<K, V>, key: K, val: V): V {
|
export function setAndGet<K, V>(map: Map<K, V>, key: K, val: V): V {
|
||||||
map.set(key, val);
|
map.set(key, val);
|
||||||
|
|
||||||
return map.get(key)!;
|
return map.get(key)!;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user