objectProperties (version 0.6.8)

properties: 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.

Value

A list that is easily concatenated into the field list

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.

Examples

Run this code
# NOT RUN {
## 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"
# }

Run the code above in your browser using DataCamp Workspace