timed: Add a timeout to a stage

Description Usage Arguments Details Value See Also Examples

Description

Add a timeout to a stage

Usage

1
timed(stage, timeout, on_timeout = function(...) NULL)

Arguments

stage

A Stage object, or a function

timeout

timeout length in seconds

on_timeout

a function to be called if a subject times out.

Details

Returns a Stage which contains the original stage. If a subject times out, 'NEXT' is returned and 'on_timeout' is called with arguments '(id, period)'.

Timed stages are implemented using http refresh. This is not a standard part of the HTTP specification, so use with caution if you do not control which browsers your subjects will be running.

Value

A Stage object of class Timed

See Also

Other stages: NEXT, WAIT, stage; checkpoint; form_stage; period; program; text_stage

Examples

1
2
3
4
5
6
s1 <- form_stage(c(header(), "Enter something",
     "<form action='' method='POST'><input name='foo'></form>", footer()),
     fields=list(foo=has_value()), data_frame="mydf")
# set a default value:
s1_timed <- timed(s1, 60, on_timeout=function(id, period)
     mydf$foo[mydf$id==id & mydf$period==period] <<- "Default value"))

hughjonesd/betr documentation built on May 17, 2019, 9:11 p.m.