Modify a timeline to execute within a loop
display_while(timeline, loop_function)
timeline | The timeline object |
---|---|
loop_function | A javascript function that returns true if loop repeats, false if terminates |
The modified timeline object
The display_while()
function is used to modify an existing
timeline
object, and provides the ability to include while loops
within an experiment. To use it, the user must supply the
loop_function
, a javascript function that executes at
runtime and should evaluate to true or false. If the
loop function returns true, then the timeline object
will execute for another iteration; this condinues until the
loop function returns false.
At present jaysire provides only limited tools for writing the
loop function. The fn_data_condition()
function allows
a simple approach that allows the loop function to query the
jsPsych data store, but only in a limited way. Future versions will
(hopefully) provide a richer tool set for this. However, for
users who are comfortable with writing javascript functions directly
the insert_javascript()
function may be useful.