Skip to content

Commit

Permalink
Moved user function to run first
Browse files Browse the repository at this point in the history
  • Loading branch information
okaycj committed May 7, 2024
1 parent a6721ba commit cabf521
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/lookit-initjspsych/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,16 @@ export const on_finish = (responseUuid: string, userFunc?: UserFunc) => {
return async function (data: DataCollection) {
const { exit_url } = window.chs.study.attributes;

// Don't call the function if not defined by user.
if (typeof userFunc === "function") {
userFunc(data);
}

await Api.finish();
await Api.updateResponse(responseUuid, {
exp_data: data.values(),
completed: true,
});
await Api.finish();

// Don't call the function if not defined by user.
if (typeof userFunc === "function") {
userFunc(data);
}

exit_url && window.location.replace(exit_url);
};
Expand Down

0 comments on commit cabf521

Please sign in to comment.