forked from PrincetonUniversity/PsyNeuLinkView
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
161 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { CallbackTypes } from '@metacell/meta-diagram'; | ||
|
||
export function handlePostUpdates(event, context) { | ||
const node = event.entity; | ||
switch (event.function) { | ||
case CallbackTypes.POSITION_CHANGED: { | ||
context.metaGraph.updateGraph( | ||
node, | ||
context.mousePos.x, | ||
context.mousePos.y, | ||
event?.extraCondition === CallbackTypes.CHILD_POSITION_CHANGED | ||
); | ||
context.interpreter.updateModel(node); | ||
return true; | ||
} | ||
case CallbackTypes.SELECTION_CHANGED: { | ||
const newInstance = node.getID(); | ||
if (context.props.instanceSelected !== newInstance) { | ||
context.props.selectInstance(newInstance); | ||
} | ||
break; | ||
} | ||
default: { | ||
console.log( | ||
'Function callback type not yet implemented ' + event.function | ||
); | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
export function handlePreUpdates(event, context) { | ||
// console.log('preUpdates not yet implemented.'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const pnlMiddleware = store => next => action => { | ||
next(action); | ||
} | ||
|
||
export default pnlMiddleware; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,26 @@ | ||
export const GENERAL_DEFAULT_STATE = { | ||
error: undefined, | ||
idsMap: {}, | ||
idsList: [], | ||
idsLoaded: 0, | ||
idsToLoad: 0, | ||
stepsToLoad: 1, | ||
stepsLoaded: 0, | ||
loading: false, | ||
instanceOnFocus : {}, | ||
ui : { | ||
canvas : { | ||
instanceSelection : {}, | ||
instanceDeleted : {}, | ||
instanceVisibilityChanged : false | ||
}, | ||
graph : { | ||
graphQueryIndex : -1, | ||
visible : true, | ||
sync : false | ||
}, | ||
termInfo : { termInfoVisible : false }, | ||
layers : { listViewerInfoVisible : true }, | ||
circuitBrowser : { | ||
circuitQuerySelected : [{ id : "", label : "" } , { id : "", label : "" }], | ||
visible : true | ||
}, | ||
layout: { | ||
"ThreeDViewer": true, | ||
"StackViewer": true, | ||
"TermInfo": true | ||
} | ||
} | ||
} | ||
import _ from 'lodash'; | ||
import logger from 'redux-logger'; | ||
import reducer from "./reducers/general"; | ||
import { configureStore } from '@reduxjs/toolkit' | ||
import pnlMiddleware from "./middleware/pnlmiddleware"; | ||
import { GENERAL_DEFAULT_STATE } from "./reducers/general"; | ||
// And use redux-batched-subscribe as an example of adding enhancers | ||
import { batchedSubscribe } from 'redux-batched-subscribe'; | ||
|
||
|
||
const INIT_STATE = { generals: GENERAL_DEFAULT_STATE }; | ||
const debounceNotify = _.debounce(notify => notify()); | ||
|
||
function initStore (state = INIT_STATE) { | ||
return configureStore({ | ||
reducer, | ||
middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(pnlMiddleware).concat(logger), | ||
devTools: process.env.NODE_ENV !== 'production', | ||
state, | ||
enhancers: [batchedSubscribe(debounceNotify)], | ||
}); | ||
} | ||
|
||
const pnlStore = initStore(INIT_STATE); | ||
|
||
export default pnlStore; |