Skip to content

Commit

Permalink
Making it clear when on_trial_start and on_trial_finish are executed. (
Browse files Browse the repository at this point in the history
…#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 b78dcc6)
  • Loading branch information
nikbpetrov authored and bjoluc committed Jun 7, 2024
2 parents 5f4c073 + b78dcc6 commit 30b5587
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/overview/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,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({
Expand All @@ -157,7 +157,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.
Expand Down

0 comments on commit 30b5587

Please sign in to comment.