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>

(rebased-with-history from commit b78dcc6830)
This commit is contained in:
Nikolay Petrov 2023-09-15 12:42:35 +03:00 committed by bjoluc
commit 30b5587973

View File

@ -142,7 +142,7 @@ var procedure = {
## on_trial_finish ## 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 ```javascript
initJsPsych({ initJsPsych({
@ -157,7 +157,7 @@ initJsPsych({
## on_trial_start ## 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 ```javascript
var current_score = 0; // a variable that is updated throughout the experiment to keep track of the current score. var current_score = 0; // a variable that is updated throughout the experiment to keep track of the current score.