registerCallback: Register a DOM Callback.

Description Usage Arguments Value Author(s) See Also Examples

Description

Register an R function as a callback. This allows callbacks to not pollute the global environment.

Usage

1

Arguments

f

A function that will be called following a DOM request such as appendChild. The function will be called with a single value, which is the result of the request.

name

The name by which the function will be known. This is the name that must be used in the DOM request.

Value

Called for its side-effect of registering the callback function.

Author(s)

Paul Murrell

See Also

htmlPage, appendChild

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
cbgen <- function() {
    count <- 0
    function(value) {
        count <<- count + 1
        cat(count, "\n")
    }
}
cb <- cbgen()
registerCallback(cb)
headlessPage <- htmlPage(client=phantomClient)
appendChild(headlessPage, htmlNode("<p>test</p>"), callback=cb)
appendChild(headlessPage, htmlNode("<p>test</p>"), callback=cb)
closePage(headlessPage)

pmur002/DOM documentation built on May 25, 2019, 10:20 a.m.