-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add: callFunction trial to call setUpPort after holdupMarkerTrial #515
Conversation
…ycomb into deprecate-psiturk
feat: Upgrade react react-bootstrap
BREAKING CHANGE: Deprecate PsiTurk
BREAKING CHANGE: Remove VOLUME equipment
Upgrade sdk mod
Visit the preview URL for this PR (updated for commit 29d7c01): https://ccv-honeycomb--pr515-add-callfunction-35azeh52.web.app (expires Wed, 07 Aug 2024 20:34:32 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 4ace1dcea913a952d2a1af84b94a4421bf36e610 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fantastic! The structure of the code is excellent. Just a minor thing about how JS executes the callback functions and you'll be on your way!
package.json
Outdated
@@ -26,6 +26,7 @@ | |||
"@electron/fuses": "^1.8.0", | |||
"@fortawesome/fontawesome-free": "^6.4.2", | |||
"@jspsych/plugin-audio-keyboard-response": "^1.1.3", | |||
"@jspsych/plugin-call-function": "^2.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! Can you actually set this to be version ^1.1.0? jsPsych just released a new version and all of their plugins have been updated as well, we want the one that's major version #1
"@jspsych/plugin-call-function": "^2.0.0", | |
"@jspsych/plugin-call-function": "^2.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! I love the way you added it as a parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!!
func: () => { | ||
func; | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Little oddness of JavaScript here! Because we're passing a callback function to the property func
we actually need to supply a callback function, and not just the call to the function itself. There's a couple ways that we can do this:
func: () => { | |
func; | |
}, | |
// 1) This way is best | |
func: func, | |
// 2) Or this would work too | |
func: () => { | |
func() | |
}, |
Notice how with option 2 we cannot pass any parameters to the function - even if we define them in startProcedure.js
! Because of this I would go with option 1, and then in startProcedure
you pass a callback function to the code we actually want to execute:
procedure.push(buildCallFunctionTrial(() => { window.electronAPI.checkSerialPort() }));
Please see this PR #524 for the change of merging it into 3.4.2 instead! |
Same code merged here #524 |
callFunction.js
: JSPsych trial that calls function passed instartProcedure.js
: calls buildCallFunctionTrial incallFunction.js
passing incheckSerialPort()
that access the electron process to callsetUpPort()
afterholdUpMarkerTrial