Remove onInvalidateHint

The recent changes to onInvalidate make it do almost exactly the same thing.
This commit is contained in:
Winston Chang
2013-01-10 14:09:03 -06:00
parent 77fab9c78f
commit 7d0de0b26f
3 changed files with 2 additions and 39 deletions

View File

@@ -5,8 +5,7 @@ Context <- setRefClass(
.label = 'character', # For debug purposes
.invalidated = 'logical',
.invalidateCallbacks = 'list',
.flushCallbacks = 'list',
.hintCallbacks = 'list'
.flushCallbacks = 'list'
),
methods = list(
initialize = function(label=NULL) {
@@ -14,7 +13,6 @@ Context <- setRefClass(
.invalidated <<- FALSE
.invalidateCallbacks <<- list()
.flushCallbacks <<- list()
.hintCallbacks <<- list()
.label <<- label
},
run = function(func) {
@@ -22,15 +20,6 @@ Context <- setRefClass(
env <- .getReactiveEnvironment()
env$runWith(.self, func)
},
invalidateHint = function() {
"Let this context know it may or may not be invalidated very soon; that
is, something in its dependency graph has been invalidated but there's no
guarantee that the cascade of invalidations will reach all the way here.
This is used to show progress in the UI."
lapply(.hintCallbacks, function(func) {
func()
})
},
invalidate = function() {
"Invalidate this context. It will immediately call the callbacks
that have been registered with onInvalidate()."
@@ -62,9 +51,6 @@ Context <- setRefClass(
"Register a function to be called when this context is flushed."
.flushCallbacks <<- c(.flushCallbacks, func)
},
onInvalidateHint = function(func) {
.hintCallbacks <<- c(.hintCallbacks, func)
},
executeFlushCallbacks = function() {
"For internal use only."
lapply(.flushCallbacks, function(func) {

View File

@@ -17,19 +17,10 @@ Dependencies <- setRefClass(
lapply(
.dependencies$values(),
function(ctx) {
ctx$invalidateHint()
ctx$invalidate()
NULL
}
)
},
invalidateHint = function() {
lapply(
.dependencies$values(),
function(dep.ctx) {
dep.ctx$invalidateHint()
NULL
})
}
)
)
@@ -133,7 +124,6 @@ Values <- setRefClass(
lapply(
mget(dep.keys, envir=.dependencies),
function(ctx) {
ctx$invalidateHint()
ctx$invalidate()
NULL
}
@@ -225,9 +215,6 @@ Observable <- setRefClass(
.dirty <<- TRUE
.dependencies$invalidate()
})
ctx$onInvalidateHint(function() {
.dependencies$invalidateHint()
})
.execCount <<- .execCount + 1L
ctx$run(function() {
.value <<- try(.func(), silent=FALSE)
@@ -286,7 +273,6 @@ Observer <- setRefClass(
fields = list(
.func = 'function',
.label = 'character',
.hintCallbacks = 'list',
.execCount = 'integer'
),
methods = list(
@@ -311,20 +297,11 @@ Observer <- setRefClass(
ctx$onInvalidate(function() {
ctx$addPendingFlush()
})
ctx$onInvalidateHint(function() {
lapply(.hintCallbacks, function(func) {
func()
NULL
})
})
ctx$onFlush(function() {
run()
})
.execCount <<- .execCount + 1L
ctx$run(.func)
},
onInvalidateHint = function(func) {
.hintCallbacks <<- c(.hintCallbacks, func)
}
)
)

View File

@@ -76,7 +76,7 @@ ShinyApp <- setRefClass(
.invalidatedOutputValues$set(name, value)
}, label)
obs$onInvalidateHint(function() {
obs$onInvalidate(function() {
showProgress(name)
})
}