Skip to contents

Wraps a method so it reacts to property changes. Used inside the methods list of createWidget() to declare which properties trigger the method.

Usage

observer(props, fn)

Arguments

props

Character vector of property names to observe.

fn

The method body: a plain function (internal) or a ts_function (exported to JS).

Value

A ts_observer object used by createWidget().

Examples

if (FALSE) { # \dontrun{
createWidget("Example",
    properties = list(x = ts_integer(1L, default = 0L)),
    methods = list(
        on_x = observer("x", function() {
            cat("x changed to", .self$x, "\n")
        })
    )
)
} # }