-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds finalize methods to R6 class (ghost issue) #606
Conversation
…ce@669_insertUI@main * origin/669_insertUI@main: [skip actions] Bump version to 0.5.1.9006 Removes 'plotly_relayout' warning from console (#601)
…ce@669_insertUI@main * origin/669_insertUI@main: fix: duplicated slices are lingering the filter panel after DDL reload (#602) [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace FilterState$destroy_observers
with finalize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works fine. Some things to consider in a future:
- public$finalize vs existing private$finalize. Is it possible to trigger
private$finalize
withoutgc()
, is it safe to destroy it that hard. - Is it relevant to include
destroy_shiny <- function()
to other classes than FilterState. Theoretically, FilteredDataset/FilterStates create some new inputs which are not destroyed (only their observers)
I believe it's safe, the object should not be used once we call Maybe via the memory address 😈 (my new favorite rlang function ft <- R6::R6Class(
"FinalizeTest",
public = list(
initialize = function() {
message(">>> Initializing")
},
am_self = function() {
rlang::obj_address(self)
}
),
private = list(
finalize = function() {
message(">>> Finalizing")
}
)
)
aa <- ft$new()
#> Initializing
message(
"obj address `{rlang::obj_address(aa)}`",
"is the same as the self address inside the R6 `{aa$am_self()}`",
.sep = " "
)
#> obj address `{rlang::obj_address(aa)}`is the same as the self address inside the R6 `{aa$am_self()}`
aa <- NULL
Sys.sleep(1)
gc(full = TRUE)
#> >>> Finalizing
#> used (Mb) gc trigger (Mb) max used (Mb)
#> Ncells 655298 35 1468394 78.5 727062 38.9
#> Vcells 1172184 9 8388608 64.0 1972780 15.1 Created on 2024-08-02 with reprex v2.1.1
Good point, something to see in the (near?) future |
WIP. Still testing with more filter option
Companion of insightsengineering/teal#1275
Changes description
FilterData
whenfinalize
method is called.How to test
observeEvent
in{teal.slice}
in order to keep track of all that are created.tmp_list
on.GlobalEnv
browser()
call somewhere with access toFilterData
object<order>_<parent r6 class>_<memory address>
finalize()
Example teal app
"observeEvent" override
Snippet to analyse ".tmp_list"