Try LIFO pendingInvalidates?

This commit is contained in:
Joe Cheng
2013-01-07 16:06:02 -08:00
committed by Winston Chang
parent 979eca4066
commit 893d72677b
2 changed files with 6 additions and 9 deletions

View File

@@ -93,16 +93,13 @@ ReactiveEnvironment <- setRefClass(
func()
},
addPendingInvalidate = function(ctx) {
.pendingInvalidate <<- c(.pendingInvalidate, ctx)
.pendingInvalidate <<- c(ctx, .pendingInvalidate)
},
flush = function() {
while (length(.pendingInvalidate) > 0) {
contexts <- .pendingInvalidate
.pendingInvalidate <<- list()
lapply(contexts, function(ctx) {
ctx$executeCallbacks()
NULL
})
ctx <- .pendingInvalidate[[1]]
.pendingInvalidate <<- .pendingInvalidate[-1]
ctx$executeCallbacks()
}
}
)

View File

@@ -52,11 +52,11 @@ test_that("isolation", {
})
flushReact()
expect_equal(execCount(funcC), 1)
countC <- execCount(funcC)
value(valueA) <- 11
flushReact()
expect_equal(execCount(funcC), 1)
expect_equal(execCount(funcC), countC)
})