-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
I have been wondering for a long while why the number of listeners keeps on increasing when the grand tour is running (qtour() in cranvas), and today I figured out the reason: simply subsetting a mutaframe can add new listeners on it. Here is an example:
library(plumbr)
library(qtbase)
library(objectSignals)
mf_listeners = function(x) listeners(plumbr:::changed(x))
mf = mutaframe(x = rnorm(5), y = rnorm(5))
add_listener(mf, function(i, j) {
timestamp()
str(mf_listeners(mf)) # print str() of mf listeners
})
# use a timer to change mf$x every 2 seconds
tm = qtimer(2000, function() {
mf$x = rnorm(5)
})
tm$start()
## there was only one listener as expected, but the line below will add a new one
mf[1, ] # this will add a listener on mfBecause all plotting functions use [] frequently, the number of listeners can increase rapidly in a tour, which makes the tour slower and slower.
Is this new listener expected? I see it comes from [.mutaframe which uses filter_proxy().
Thanks!
Metadata
Metadata
Assignees
Labels
No labels