reactivePoll
works by pairing a relatively cheap
"check" function with a more expensive value retrieval
function. The check function will be executed
periodically and should always return a consistent value
until the data changes. When the check function returns a
different value, then the value retrieval function will
be used to re-populate the data. Note that the check function doesn't return TRUE
or FALSE
to indicate whether the underlying data
has changed. Rather, the check function indicates change
by returning a different value from the previous time it
was called.
For example, reactivePoll
is used to implement
reactiveFileReader
by pairing a check function
that simply returns the last modified timestamp of a
file, and a value retrieval function that actually reads
the contents of the file.
As another example, one might read a relational database
table reactively by using a check function that does
SELECT MAX(timestamp) FROM table
and a value
retrieval function that does SELECT * FROM table
.
The intervalMillis
, checkFunc
, and
valueFunc
functions will be executed in a reactive
context; therefore, they may read reactive values and
reactive expressions.