mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 19:20:55 +00:00
Updated plugin-development docs to reflect plugin-changes
This commit is contained in:
parent
b7bd08aaac
commit
f6662098be
@ -38,33 +38,46 @@ The only requirement for the `trial` method is that it calls `jsPsych.finishTria
|
|||||||
|
|
||||||
### static info
|
### static info
|
||||||
|
|
||||||
The plugin's `info` property is an object with a `name` and `parameters` property.
|
The plugin's `info` property is an object with a `name`, `version`, `parameters`, and `data` property.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const info = {
|
const info = {
|
||||||
name: 'my-awesome-plugin',
|
name: 'my-awesome-plugin',
|
||||||
parameters: { }
|
version: version,
|
||||||
|
parameters: { },
|
||||||
|
data: { }
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The `version` field should imported from the package.json file by including an import statement in the top of the index.ts file. This lets the `version` field be automatically updated with each changeset.
|
||||||
|
|
||||||
The `parameters` property is an object containing all of the parameters for the plugin. Each parameter has a `type` and `default` property.
|
The `parameters` property is an object containing all of the parameters for the plugin. Each parameter has a `type` and `default` property.
|
||||||
|
|
||||||
|
The `data` field is similar to the `parameters` property, except it does not include a `default` property. Additionally, the `data` describes data that is only generated, and should be only used for data you generate not the default data. Any javadoc you include will be scraped as metadata if you are choosing to generate metadata.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const info = {
|
const info = {
|
||||||
name: 'my-awesome-plugin',
|
name: 'my-awesome-plugin',
|
||||||
parameters: {
|
parameters: {
|
||||||
image: {
|
image: {
|
||||||
type: jspsych.ParameterType.IMAGE,
|
type: ParameterType.IMAGE,
|
||||||
default: undefined
|
default: undefined
|
||||||
},
|
},
|
||||||
image_duration: {
|
image_duration: {
|
||||||
type: jspsych.ParameterType.INT,
|
type: ParameterType.INT,
|
||||||
default: 500
|
default: 500
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
data: {
|
||||||
|
/** This will become metadata describing response. */
|
||||||
|
response: {
|
||||||
|
type: ParameterType.STRING,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
If the `default` value is `undefined` then a user must specify a value for this parameter when creating a trial using the plugin on the timeline. If they do not, then an error will be generated and shown in the console. If a `default` value is specified in `info` then that value will be used by the plugin unless the user overrides it by specifying that property.
|
If the `default` value is `undefined` then a user must specify a value for this parameter when creating a trial using the plugin on the timeline. If they do not, then an error will be generated and shown in the console. If a `default` value is specified in `info` then that value will be used by the plugin unless the user overrides it by specifying that property.
|
||||||
|
|
||||||
jsPsych allows most [plugin parameters to be dynamic](../overview/dynamic-parameters.md), which means that the parameter value can be a function that will be evaluated right before the trial starts. However, if you want your plugin to have a parameter that is a function that _shouldn't_ be evaluated before the trial starts, then you should make sure that the parameter type is `'FUNCTION'`. This tells jsPsych not to evaluate the function as it normally does for dynamic parameters. See the `canvas-*` plugins for examples.
|
jsPsych allows most [plugin parameters to be dynamic](../overview/dynamic-parameters.md), which means that the parameter value can be a function that will be evaluated right before the trial starts. However, if you want your plugin to have a parameter that is a function that _shouldn't_ be evaluated before the trial starts, then you should make sure that the parameter type is `'FUNCTION'`. This tells jsPsych not to evaluate the function as it normally does for dynamic parameters. See the `canvas-*` plugins for examples.
|
||||||
@ -74,6 +87,7 @@ The `info` object should be a `static` member of the class, as shown below.
|
|||||||
```js
|
```js
|
||||||
const info = {
|
const info = {
|
||||||
name: 'my-awesome-plugin',
|
name: 'my-awesome-plugin',
|
||||||
|
version: version,
|
||||||
parameters: {
|
parameters: {
|
||||||
image: {
|
image: {
|
||||||
type: jspsych.ParameterType.IMAGE,
|
type: jspsych.ParameterType.IMAGE,
|
||||||
@ -84,6 +98,12 @@ const info = {
|
|||||||
default: 500
|
default: 500
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
data: {
|
||||||
|
/** This will become metadata describing response. */
|
||||||
|
response: {
|
||||||
|
type: ParameterType.STRING,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyAwesomePlugin {
|
class MyAwesomePlugin {
|
||||||
|
Loading…
Reference in New Issue
Block a user