Add checkInputandOutput function to flowStore.ts
This commit is contained in:
parent
383152aa4b
commit
9c0d794dd1
1 changed files with 17 additions and 0 deletions
|
|
@ -20,6 +20,8 @@ import {
|
||||||
cleanEdges,
|
cleanEdges,
|
||||||
getHandleId,
|
getHandleId,
|
||||||
getNodeId,
|
getNodeId,
|
||||||
|
isInputNode,
|
||||||
|
isOutputNode,
|
||||||
scapeJSONParse,
|
scapeJSONParse,
|
||||||
scapedJSONStringfy,
|
scapedJSONStringfy,
|
||||||
} from "../utils/reactflowUtils";
|
} from "../utils/reactflowUtils";
|
||||||
|
|
@ -153,6 +155,21 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
checkInputandOutput: () => {
|
||||||
|
let has_input = false;
|
||||||
|
let has_output = false;
|
||||||
|
const nodes = get().nodes;
|
||||||
|
nodes.forEach((node) => {
|
||||||
|
const nodeData: NodeDataType = node.data as NodeDataType;
|
||||||
|
if (isInputNode(nodeData)) {
|
||||||
|
has_input = true;
|
||||||
|
}
|
||||||
|
if (isOutputNode(nodeData)) {
|
||||||
|
has_output = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return has_input && has_output;
|
||||||
|
},
|
||||||
getNode: (id: string) => {
|
getNode: (id: string) => {
|
||||||
return get().nodes.find((node) => node.id === id);
|
return get().nodes.find((node) => node.id === id);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue