mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 19:20:55 +00:00
Update plugin-development.md
This commit is contained in:
parent
4971d129f6
commit
b560575dc1
@ -8,9 +8,11 @@ As of version 7.0, plugins are [JavaScript Classes](https://developer.mozilla.or
|
|||||||
* [A `trial()` method](#trial) that accepts an `HTMLElement` as its first argument and an `object` of trial parameters as its second argument. There is an optional third argument to [handle the `on_load` event](#asynchronous-loading) in certain cirumstances. The `trial()` method should *either* invoke `jsPsych.finishTrial()` or should be an `async` function that returns a data object to [end the trial and save data](#save-data).
|
* [A `trial()` method](#trial) that accepts an `HTMLElement` as its first argument and an `object` of trial parameters as its second argument. There is an optional third argument to [handle the `on_load` event](#asynchronous-loading) in certain cirumstances. The `trial()` method should *either* invoke `jsPsych.finishTrial()` or should be an `async` function that returns a data object to [end the trial and save data](#save-data).
|
||||||
* [A static `info` property](#static-info) on the class that contains an object describing the plugin's parameters, data generated, and version.
|
* [A static `info` property](#static-info) on the class that contains an object describing the plugin's parameters, data generated, and version.
|
||||||
|
|
||||||
### Templates
|
## Plugin templates
|
||||||
|
|
||||||
Plugins can be written in either plain JavaScript or in TypeScript. Template files for both [JavaScript](https://github.com/jspsych/jspsych-contrib/blob/main/templates/plugin-template-js/src/index.js) and [TypeScript](https://github.com/jspsych/jspsych-contrib/blob/main/templates/plugin-template-ts/src/index.ts) are available in the [jspsych-contrib repository](https://github.com/jspsych/jspsych-contrib/).
|
Templates for plugins are available in the [jspsych-contrib](https://github.com/jspsych/jspsych-contrib) repository. Plugins can be written in either plain [JavaScript](https://github.com/jspsych/jspsych-contrib/blob/main/templates/plugin-template-js/src/index.js) or in [TypeScript](https://github.com/jspsych/jspsych-contrib/blob/main/templates/plugin-template-ts/src/index.ts).
|
||||||
|
|
||||||
|
Additionally, `jspsych-contrib` offers guidance for either approach in its [`README`](https://github.com/jspsych/jspsych-contrib) file. It is likewise (for now) the exclusive home for CLI tools like `npm run new`, which we've built to help developers get started. Those relying on Typescript can then use the `npm run build` command to compile their `index.ts` code into Javascript files. Meanwhile, those templating directly in Javascript can run their trial code using the `trial()` method, as detailed below.
|
||||||
|
|
||||||
## Plugin components
|
## Plugin components
|
||||||
|
|
||||||
@ -328,8 +330,4 @@ If you are developing a plugin with the aim of including it in the main jsPsych
|
|||||||
|
|
||||||
We also recommend that you make your plugin *as general as possible*. Consider using parameters to give the user of the plugin as many options for customization as possible. For example, if you have any text that displays in the plugin including things like button labels, implement the text as a parameter. This allows users running experiments in other languages to replace text values as needed.
|
We also recommend that you make your plugin *as general as possible*. Consider using parameters to give the user of the plugin as many options for customization as possible. For example, if you have any text that displays in the plugin including things like button labels, implement the text as a parameter. This allows users running experiments in other languages to replace text values as needed.
|
||||||
|
|
||||||
## Plugin templates
|
|
||||||
|
|
||||||
Templates for plugins are available in the [jspsych-contrib](https://github.com/jspsych/jspsych-contrib) repository. There is a command-line tool for generating a new plugin from these templates in that repository. See the README file in the jspsych-contrib repository for more information.
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user