Skip to content
Snippets Groups Projects
Commit 665032e4 authored by Robin Leber's avatar Robin Leber
Browse files

state ausgliedern

parent 19ec6667
No related branches found
No related tags found
No related merge requests found
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import { createEndpoints } from "./endpoints"; import { createEndpoints } from "./endpoints";
import { appState } from "./state";
export const duplicatePipe = (instance) => { export const duplicatePipe = (instance) => {
var selectedPipe = document.getElementById(window.selectedPipe); var selectedPipe = document.getElementById(window.selectedPipe);
... ...
......
export const appState = (() => {
let state = {
beenPaused: false,
connections: new Map([]),
pipes: new Map([]),
};
return {
getState: () => state,
setBeenPaused: (beenPaused) => (state.beenPaused = beenPaused),
addConnection: (con1, con2) => {
state.connections.set(con1, con2);
},
removeConnection: (con1) => {
state.connections.delete(con1);
},
getConnection: (con1) => {
return state.connections.get(con1);
},
addPipe: (pipeId, pipeName) => {
state.pipes.set(pipeId, pipeName);
},
removePipe: (pipeId) => {
state.pipes.delete(pipeId);
},
getPipe: (pipeId) => {
return state.pipes.get(pipeId);
},
};
})();
...@@ -5,6 +5,7 @@ import { INTERCEPT_BEFORE_DROP } from "@jsplumb/browser-ui"; ...@@ -5,6 +5,7 @@ import { INTERCEPT_BEFORE_DROP } from "@jsplumb/browser-ui";
import { isConnectionAllowed } from "./functions/isConnectionAllowed"; import { isConnectionAllowed } from "./functions/isConnectionAllowed";
import { initContextmenu } from "./functions/contextmenu"; import { initContextmenu } from "./functions/contextmenu";
import { createEndpoints } from "./functions/endpoints"; import { createEndpoints } from "./functions/endpoints";
import { appState } from "./functions/state";
import { import {
runCustomCode, runCustomCode,
stopCustomCode, stopCustomCode,
...@@ -14,16 +15,6 @@ import { ...@@ -14,16 +15,6 @@ import {
import { getScaleValues } from "./functions/scaling"; import { getScaleValues } from "./functions/scaling";
function App() { function App() {
const appState = (() => {
let state = {
beenPaused: false,
};
return {
getState: () => state,
setBeenPaused: (beenPaused) => (state.beenPaused = beenPaused),
};
})();
const instance = jsPlumb.getInstance({}); const instance = jsPlumb.getInstance({});
instance.setContainer("diagram"); instance.setContainer("diagram");
instance.ready(() => { instance.ready(() => {
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment