Skip to content
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

Removal of on_data_update event #2736

Open
Shaobin-Jiang opened this issue Aug 2, 2022 · 5 comments · Fixed by #3167
Open

Removal of on_data_update event #2736

Shaobin-Jiang opened this issue Aug 2, 2022 · 5 comments · Fixed by #3167
Assignees

Comments

@Shaobin-Jiang
Copy link
Contributor

The on_trial_finish event and the on_data_update event both are only called once, inside the finishTrial method:

// handle callback at whole-experiment level
this.opts.on_trial_finish(trial_data_values);
// after the above callbacks are complete, then the data should be finalized
// for this trial. call the on_data_update handler, passing in the same
// data object that just went through the trial's finish handlers.
this.opts.on_data_update(trial_data_values);

They are called side by side, and have the same data object passed to both, so at least personally, I do not think that the existence of on_data_update is actually necessary in the way it is currently working in, and it might probably be better to simply remove this.

@jodeleeuw
Copy link
Member

@bjoluc -- thoughts on this as part of 8.0?

@bjoluc
Copy link
Member

bjoluc commented Oct 14, 2022

Great catch @Shaobin-Jiang, let's remove on_data_update in 8.0 🎉

@bjoluc bjoluc added this to the 8.0 milestone Oct 14, 2022
@bjoluc bjoluc moved this to Todo in jsPsych v8 Jun 10, 2023
@bjoluc bjoluc self-assigned this Jun 10, 2023
@jodeleeuw
Copy link
Member

Quick thought about that came up working with another project:

Would it make sense to keep this event and have it trigger anytime the jsPsych.data object is updated? In its current form it doesn't do this, but if it did then it would allow people to stick reliable backend data handlers inside the on_data_update event.

@bjoluc
Copy link
Member

bjoluc commented Nov 8, 2023

and have it trigger anytime the jsPsych.data object is updated?

You mean after on_trial_finish and after jsPsych.data.addToAll or jsPsych.data.addToLast?

@Shaobin-Jiang
Copy link
Contributor Author

have it trigger anytime the jsPsych.data object is updated

I think what @jodeleeuw means here is that we monitor the change of the jsPsych.data object somehow, like adding a callback or something. Instead of triggering after particular events, it triggers whenever the object is updated.

It is tricky, and I might suggest using a proxy for that, but proxies do have their limitations, so I am at a loss as to how this might be done properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

3 participants