mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-12 08:38:11 +00:00

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.
33 lines
863 B
TypeScript
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;
|