Merge pull request #837 from rstudio/joe/bugfix/callbacks-fifo

Ensure that callbacks fire in a FIFO order
This commit is contained in:
Joe Cheng
2015-05-20 14:32:46 -07:00
3 changed files with 25 additions and 1 deletions

View File

@@ -23,6 +23,9 @@ Map <- R6Class(
env[[key]] <- value
value
},
mget = function(keys) {
base::mget(keys, env)
},
mset = function(...) {
args <- list(...)
if (length(args) == 0)

View File

@@ -580,7 +580,11 @@ Callbacks <- R6Class(
})
},
invoke = function(..., onError=NULL) {
for (callback in .callbacks$values()) {
# Ensure that calls are invoked in the order that they were registered
keys <- as.character(sort(as.integer(.callbacks$keys()), decreasing = TRUE))
callbacks <- .callbacks$mget(keys)
for (callback in callbacks) {
if (is.null(onError)) {
callback(...)
} else {