mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
Addressing last batch of PR comments
This commit is contained in:
parent
b8bffb5980
commit
b690802ed6
@ -4,12 +4,12 @@
|
||||
|
||||
As of version 7.0, extensions are [JavaScript Classes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes). An extension must implement:
|
||||
|
||||
* [A `constructor()`](#constructor) that accepts an instance of jsPsych.
|
||||
* [An `initialize()` function](#initialize) to handle the initialize event of the extension.
|
||||
* [An `on_start()` function](#on_start) to handle the on_start event of the extension.
|
||||
* [An `on_load()` function](#on_load) to handle the on_load event of the extension.
|
||||
* [An `on_finish()` function](#on_finish) to handle the on_finish event of the extension and store data that the extension collects.
|
||||
* [A static `info`](#static-info) property containing a unique name, version parameter and data property for the extension.
|
||||
- [A `constructor()`](#constructor) that accepts an instance of jsPsych.
|
||||
- [An `initialize()` function](#initialize) to handle the initialize event of the extension.
|
||||
- [An `on_start()` function](#on_start) to handle the on_start event of the extension.
|
||||
- [An `on_load()` function](#on_load) to handle the on_load event of the extension.
|
||||
- [An `on_finish()` function](#on_finish) to handle the on_finish event of the extension and store data that the extension collects.
|
||||
- [A static `info`](#static-info) property containing a unique name, version parameter, and data property for the extension.
|
||||
|
||||
### Templates
|
||||
|
||||
@ -79,7 +79,6 @@ class MyAwesomeExtension {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### on_load()
|
||||
|
||||
`on_load()` is called after the `on_load` event for the plugin has completed, which is typically when the plugin has finished executing initial DOM-modifying code and has set up various event listeners. This is where the extension can begin actively interacting with the DOM and recording data. The `params` object is passed from the declaration of the extension in the trial object. You can use `params` to customize the behavior of the extension for each trial.
|
||||
@ -110,7 +109,7 @@ class MyAwesomeExtension {
|
||||
|
||||
### on_finish()
|
||||
|
||||
`on_finish()` is called after the plugin invokes `jsPsych.finishTrial()`. This can be used for any teardown at the end of the trial. This method should return an object of data to append to the plugin's data. Note that this event fires *before* the `on_finish` event for the plugin, so data added by the extension is accessible in any trial `on_finish` event handlers. The `params` object is passed from the declaration of the extension in the trial object. You can use `params` to customize the behavior of the extension for each trial.
|
||||
`on_finish()` is called after the plugin invokes `jsPsych.finishTrial()`. This can be used for any teardown at the end of the trial. This method should return an object of data to append to the plugin's data. Note that this event fires _before_ the `on_finish` event for the plugin, so data added by the extension is accessible in any trial `on_finish` event handlers. The `params` object is passed from the declaration of the extension in the trial object. You can use `params` to customize the behavior of the extension for each trial.
|
||||
|
||||
```js
|
||||
//... experiment code ...//
|
||||
@ -155,9 +154,9 @@ class MyAwesomeExtension {
|
||||
|
||||
MyAwesomeExtension.info = {
|
||||
name: 'awesome',
|
||||
version: version, // can also be hardcoded as `version: "1.0.1"`
|
||||
version: version, // Should be hardcoded as `version: "1.0.1"` if not using build tools.
|
||||
data: {
|
||||
/** This will be scraped as metadata describing tracking_data. */
|
||||
/** This will be scraped as metadata describing tracking_data and used to create the JsPsych docs */
|
||||
tracking_data: {
|
||||
type: ParameterType.STRING,
|
||||
}
|
||||
@ -167,7 +166,7 @@ MyAwesomeExtension.info = {
|
||||
|
||||
The `version` field describes the version of the extension used and then durin the experiment will be part of the generated data. This is used generate metadata and help maintain the Psych-DS standard. It should imported from the package.json file by including an import statement in the top of the index.ts file. This allows the `version` field be automatically updated with each changeset. If you are not using a build environment and instead writing a plain JS file, you can manually enter the `version` as a string as done in the comment.
|
||||
|
||||
The `data` field is an object containing all of the `data` generated for the plugin. Each 'data' object has a `type` and `default` property. Additionally, this should be only used for data you choose to generate. Any javadoc you include will be scraped as metadata if you are choosing to generate metadata.
|
||||
The `data` field is an object containing all of the `data` generated for the plugin. Each 'data' object has a `type` and `default` property. Additionally, this should be only used for data you choose to generate. Any jsdoc (comments included in the /** */ tags) you include will be scraped as metadata if you are choosing to generate metadata. This scraped metadata will also be used to create the JsPsych documentation.
|
||||
|
||||
### Optional methods
|
||||
|
||||
|
@ -40,17 +40,17 @@ export class Trial extends TimelineNode {
|
||||
if (!("version" in this.pluginInfo) && !("data" in this.pluginInfo)) {
|
||||
console.warn(
|
||||
this.pluginInfo["name"],
|
||||
"is missing the 'version' and 'data' fields. Please update plugin as 'version' and 'data' will be required in v9."
|
||||
"is missing the 'version' and 'data' fields. Please update plugin as 'version' and 'data' will be required in v9. See https://www.jspsych.org/latest/developers/plugin-development/ for more details."
|
||||
);
|
||||
} else if (!("version" in this.pluginInfo)) {
|
||||
console.warn(
|
||||
this.pluginInfo["name"],
|
||||
"is missing the 'version' field. Please update plugin as 'version' will be required in v9."
|
||||
"is missing the 'version' field. Please update plugin as 'version' will be required in v9. See https://www.jspsych.org/latest/developers/plugin-development/ for more details."
|
||||
);
|
||||
} else if (!("data" in this.pluginInfo)) {
|
||||
console.warn(
|
||||
this.pluginInfo["name"],
|
||||
"is missing the 'data' field. Please update plugin as 'data' will be required in v9."
|
||||
"is missing the 'data' field. Please update plugin as 'data' will be required in v9. See https://www.jspsych.org/latest/developers/plugin-development/ for more details."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user