jsPsych/packages/jspsych/tests/extensions/test-extension.ts
bjoluc c119650471 Move experiment execution into jsPsych.run()
The `run()` method takes a timeline and returns a promise that is
resolved when the experiment finishes.
Hence, jsPsych can now be initialized without starting an experiment.
This re-enables usage of `jsPsych.timelineVariable()` in timeline
definitions and repairs exclusion checks and extension loading.
2021-07-19 17:10:37 +02:00

33 lines
863 B
TypeScript

const extension = <any>{};
// private state for the extension
// extension authors can define public functions to interact
// with the state. recommend not exposing state directly
// so that state manipulations are checked.
var state = {};
// required, will be called at jsPsych.init
// should return a Promise
extension.initialize = (params) => {
return new Promise<void>((resolve, reject) => {
resolve();
});
};
// required, will be called when the trial starts (before trial loads)
extension.on_start = (params) => {};
// required will be called when the trial loads
extension.on_load = (params) => {};
// required, will be called when jsPsych.finishTrial() is called
// must return data object to be merged into data.
extension.on_finish = (params) => {
// send back data
return {
extension_data: true,
};
};
export default extension;