properties {objectProperties}R Documentation

Properties signaling fileds

Description

Convenience function for defining a set of reference class fields that signals when set.

Usage

properties(fields=list(), prototype=list())

Arguments

fields

list of names of the field and associated fields class

prototype

A list of values declaring a default value for a field.

Details

When constructing signaling fields in this way, each field has the ability to register its own signal and at the same time, there is one top level signal which could be emitted no matter which field changes. Please see the example to learn to register global signal and individual signal.

Value

A list that is easily concatenated into the field list

Author(s)

Michael Lawrence, Tengfei Yin

Examples

## we could pass prototype as in S4
GPars.gen <- setRefClass("GraphicProperties",
                fields = properties(fields = list(size = "numeric",
                                                  color = "character"),
                                    prototype = list(size =1,
                                                     color = "red")))

obj <- GPars.gen$new()
## since it's not PropertySet, no global signal
## let's register individual signal
obj$sizeChanged$connect(function(){
  print("size changed")
})
## emit signal
obj$size <- 3
## no signal
obj$color <- "black"

[Package objectProperties version 0.6.8 Index]