Making it clear when on_trial_start and on_trial_finish are executed. (#3118)

* Making it clear when on_trial_start and on_trial_finish are executed.

* Update docs/overview/events.md

Co-authored-by: bjoluc <mail@bjoluc.de>

* Update docs/overview/events.md

Co-authored-by: bjoluc <mail@bjoluc.de>

---------

Co-authored-by: bjoluc <mail@bjoluc.de>
This commit is contained in:
Nikolay Petrov 2023-09-15 12:42:35 +03:00 committed by GitHub
parent 6d8aca9881
commit b78dcc6830
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -146,7 +146,7 @@ var procedure = {
## on_trial_finish
The `on_trial_finish` callback can be declared in the `initJsPsych` method. The callback will trigger at the end of every trial in the experiment. If you want a callback to trigger only for the end of certain trials, use the [`on_finish`](#onfinishtrial) callback on the trial object. The callback function will be passed a single argument, containing the data object from the trial.
The `on_trial_finish` callback can be declared in the `initJsPsych` method. The callback will trigger at the end of every trial in the experiment, after the trial object's [`on_finish`](#onfinishtrial) callback has been run. The callback function will be passed a single argument, containing the data object from the trial. If you want a callback to trigger only for the end of certain trials, use the [`on_finish`](#onfinishtrial) callback on the trial object instead.
```javascript
initJsPsych({
@ -161,7 +161,7 @@ initJsPsych({
## on_trial_start
The `on_trial_start` callback can be declared in the `initJsPsych` method. The callback will trigger at the start of every trial in the experiment. The function receives a single argument: a modifiable copy of the trial object that will be used to run the next trial. Changes can be made to this object to alter the parameters of the upcoming trial.
The `on_trial_start` callback can be declared in the `initJsPsych` method. The callback will trigger at the start of every trial in the experiment, before the trial-specific `on_start` callback is executed. The function receives a single argument: a modifiable copy of the trial object that will be used to run the next trial. Changes can be made to this object to alter the parameters of the upcoming trial.
```javascript
var current_score = 0; // a variable that is updated throughout the experiment to keep track of the current score.