Skip to content

Commit

Permalink
use readonly set/map
Browse files Browse the repository at this point in the history
  • Loading branch information
sc420 committed Apr 6, 2024
1 parent 96be100 commit 0311c94
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import EditOperationDialog from "./EditOperationDialog";

interface AddNodesPanelProps {
featureOperations: FeatureOperation[];
operationIdsAddedAtLeastOnce: Set<string>;
operationIdsAddedAtLeastOnce: ReadonlySet<string>;
isDarkMode: boolean;
onAddNode: (featureNodeType: FeatureNodeType) => void;
onAddOperation: () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import EditOperationTabPanel from "./EditOperationTabPanel";
interface EditOperationDialogProps {
open: boolean;
readOperation: FeatureOperation;
operationIdsAddedAtLeastOnce: Set<string>;
operationIdsAddedAtLeastOnce: ReadonlySet<string>;
isDarkMode: boolean;
onCancel: () => void;
onSave: (updatedOperation: FeatureOperation) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import TutorialPanel from "./TutorialPanel";
interface FeaturePanelProps {
feature: SelectedFeature;
featureOperations: FeatureOperation[];
operationIdsAddedAtLeastOnce: Set<string>;
operationIdsAddedAtLeastOnce: ReadonlySet<string>;
isDarkMode: boolean;
hasNodes: boolean;
hasDerivativeTarget: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ const GraphContainer: FunctionComponent<GraphContainerProps> = ({
);

const handleFValuesUpdated = useCallback(
(nodeIdToFValues: Map<string, string>) => {
(nodeIdToFValues: ReadonlyMap<string, string>) => {
setReactFlowNodes((nodes) =>
updateReactFlowNodeFValues(nodeIdToFValues, nodes),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class NodeRelationship {
}

private getPortDataByPort(
portIdToPortData: Map<string, PortData>,
portIdToPortData: ReadonlyMap<string, PortData>,
portId: string,
): PortData {
const portData = portIdToPortData.get(portId);
Expand Down
12 changes: 8 additions & 4 deletions interactive-computational-graph/src/features/CoreGraphAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ type ShowInputFieldsCallback = (emptyPortEdges: Edge[]) => void;

type HideInputFieldCallback = (nonEmptyPortConnection: Connection) => void;

type FValuesUpdatedCallback = (nodeIdToFValues: Map<string, string>) => void;
type FValuesUpdatedCallback = (
nodeIdToFValues: ReadonlyMap<string, string>,
) => void;

type DerivativeValuesUpdatedCallback = (
differentiationMode: DifferentiationMode,
Expand Down Expand Up @@ -687,15 +689,17 @@ cycle`;
});
}

private emitFValuesUpdated(nodeIdToFValues: Map<string, string>): void {
private emitFValuesUpdated(
nodeIdToFValues: ReadonlyMap<string, string>,
): void {
this.fValuesUpdatedCallbacks.forEach((callback) => {
callback(nodeIdToFValues);
});
}

private emitDerivativeValuesUpdated(
nodeIdToDerivatives: Map<string, string>,
nodeIdToNames: Map<string, string>,
nodeIdToDerivatives: ReadonlyMap<string, string>,
nodeIdToNames: ReadonlyMap<string, string>,
): void {
const targetNode = this.graph.getTargetNode();
this.derivativesUpdatedCallbacks.forEach((callback) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ const updateEdgeAnimations = (
};

const updateReactFlowNodeFValues = (
updatedNodeIdToValues: Map<string, string>,
updatedNodeIdToValues: ReadonlyMap<string, string>,
nodes: Node[],
): Node[] => {
return nodes.map((node) => {
Expand Down

0 comments on commit 0311c94

Please sign in to comment.