Skip to content

Commit d63f30c

Browse files
averissimollrs-rochegithub-actions[bot]
authored
Fixes R6 warnings when loading package (#658)
# Pull Request - Fixes #657 ### Changes description - Move `finalize()` methods - Create public `destroy()` methods as these methods are called recursively --------- Signed-off-by: André Veríssimo <[email protected]> Co-authored-by: Lluís Revilla <[email protected]> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 63aae72 commit d63f30c

24 files changed

+146
-156
lines changed

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# teal.slice 0.6.0.9008
22

3+
### Miscellaneous
4+
5+
* In R6 classes `finalize()` method is moved to private and is replaced in public API by `destroy()` (#658).
6+
37
# teal.slice 0.6.0
48

59
### Enhancements

R/FilterState.R

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ FilterState <- R6::R6Class( # nolint
113113
})
114114
},
115115

116+
#' @description Destroys a `FilterState` object.
117+
destroy = function() private$finalize(),
118+
116119
#' @description
117120
#' Returns a formatted string representing this `FilterState` object.
118121
#'
@@ -385,17 +388,6 @@ FilterState <- R6::R6Class( # nolint
385388
)
386389
)
387390
)
388-
},
389-
390-
#' @description
391-
#' Destroy inputs and observers stored in `private$session_bindings`.
392-
#'
393-
#'
394-
#' @return `NULL`, invisibly.
395-
#'
396-
finalize = function() {
397-
.finalize_session_bindings(self, private)
398-
invisible(NULL)
399391
}
400392
),
401393

@@ -793,6 +785,16 @@ FilterState <- R6::R6Class( # nolint
793785
)
794786
invisible(NULL)
795787
})
788+
},
789+
790+
#' @description
791+
#' Destroy inputs and observers stored in `private$session_bindings`.
792+
#'
793+
#'
794+
#' @return `NULL`, invisibly.
795+
#'
796+
finalize = function() {
797+
.finalize_session_bindings(self, private)
796798
}
797799
)
798800
)

R/FilterStateExpr.R

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ FilterStateExpr <- R6::R6Class( # nolint
7878
invisible(self)
7979
},
8080

81+
#' @description Destroys a `FilterStateExpr` object.
82+
destroy = function() private$finalize(),
83+
8184
#' @description
8285
#' Returns a formatted string representing this `FilterStateExpr` object.
8386
#'
@@ -140,16 +143,6 @@ FilterStateExpr <- R6::R6Class( # nolint
140143
isolate(str2lang(private$teal_slice$expr))
141144
},
142145

143-
#' @description
144-
#' Destroy inputs and observers stored in `private$session_bindings`.
145-
#'
146-
#' @return `NULL`, invisibly.
147-
#'
148-
finalize = function() {
149-
.finalize_session_bindings(self, private)
150-
invisible(NULL)
151-
},
152-
153146
# public shiny modules ----
154147

155148
#' @description
@@ -276,6 +269,15 @@ FilterStateExpr <- R6::R6Class( # nolint
276269
},
277270
content_summary = function() {
278271
isolate(private$teal_slice$expr)
272+
},
273+
274+
#' @description
275+
#' Destroy inputs and observers stored in `private$session_bindings`.
276+
#'
277+
#' @return `NULL`, invisibly.
278+
#'
279+
finalize = function() {
280+
.finalize_session_bindings(self, private)
279281
}
280282
)
281283
)

R/FilterStates.R

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ FilterStates <- R6::R6Class( # nolint
7777
invisible(self)
7878
},
7979

80+
#' @description Destroys a `FilterStates` object.
81+
destroy = function() private$finalize(),
82+
8083
#' @description
8184
#' Returns a formatted string representing this `FilterStates` object.
8285
#'
@@ -507,19 +510,6 @@ FilterStates <- R6::R6Class( # nolint
507510
NULL
508511
}
509512
)
510-
},
511-
512-
#' @description
513-
#' Object cleanup.
514-
#'
515-
#' - Destroy inputs and observers stored in `private$session_bindings`
516-
#' - Clean `state_list`
517-
#'
518-
#' @return `NULL`, invisibly.
519-
#'
520-
finalize = function() {
521-
.finalize_session_bindings(self, private)
522-
invisible(NULL)
523513
}
524514
),
525515
private = list(
@@ -662,7 +652,7 @@ FilterStates <- R6::R6Class( # nolint
662652
if (state$get_state()$anchored && !force) {
663653
TRUE
664654
} else {
665-
state$finalize()
655+
state$destroy()
666656
FALSE
667657
}
668658
} else {
@@ -768,6 +758,18 @@ FilterStates <- R6::R6Class( # nolint
768758

769759
invisible(NULL)
770760
})
761+
},
762+
763+
#' @description
764+
#' Object cleanup.
765+
#'
766+
#' - Destroy inputs and observers stored in `private$session_bindings`
767+
#' - Clean `state_list`
768+
#'
769+
#' @return `NULL`, invisibly.
770+
#'
771+
finalize = function() {
772+
.finalize_session_bindings(self, private)
771773
}
772774
)
773775
)

R/FilteredData.R

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ FilteredData <- R6::R6Class( # nolint
134134
invisible(self)
135135
},
136136

137+
#' @description Destroys a `FilteredData` object.
138+
destroy = function() private$finalize(),
139+
137140
#' @description
138141
#' Gets `datanames`.
139142
#' @details
@@ -829,19 +832,6 @@ FilteredData <- R6::R6Class( # nolint
829832
NULL
830833
}
831834
)
832-
},
833-
834-
#' @description
835-
#' Object and dependencies cleanup.
836-
#'
837-
#' - Destroy inputs and observers stored in `private$session_bindings`
838-
#' - Finalize `FilteredData` stored in `private$filtered_datasets`
839-
#'
840-
#' @return `NULL`, invisibly.
841-
finalize = function() {
842-
.finalize_session_bindings(self, private)
843-
lapply(private$filtered_datasets, function(x) x$finalize())
844-
invisible(NULL)
845835
}
846836
),
847837

@@ -1031,6 +1021,19 @@ FilteredData <- R6::R6Class( # nolint
10311021
}
10321022
)
10331023
})
1024+
},
1025+
1026+
#' @description
1027+
#' Object and dependencies cleanup.
1028+
#'
1029+
#' - Destroy inputs and observers stored in `private$session_bindings`
1030+
#' - Finalize `FilteredData` stored in `private$filtered_datasets`
1031+
#'
1032+
#' @return `NULL`, invisibly.
1033+
finalize = function() {
1034+
.finalize_session_bindings(self, private)
1035+
lapply(private$filtered_datasets, function(x) x$destroy())
1036+
invisible(NULL)
10341037
}
10351038
)
10361039
)

R/FilteredDataset.R

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ FilteredDataset <- R6::R6Class( # nolint
5959
invisible(self)
6060
},
6161

62+
#' @description Destroys a `FilteredDataset` object.
63+
destroy = function() private$finalize(),
64+
65+
6266
#' @description
6367
#' Returns a formatted string representing this `FilteredDataset` object.
6468
#'
@@ -459,19 +463,6 @@ FilteredDataset <- R6::R6Class( # nolint
459463
NULL
460464
}
461465
)
462-
},
463-
464-
#' @description
465-
#' Object and dependencies cleanup.
466-
#'
467-
#' - Destroy inputs and observers stored in `private$session_bindings`
468-
#' - Finalize `FilterStates` stored in `private$filter_states`
469-
#'
470-
#' @return `NULL`, invisibly.
471-
finalize = function() {
472-
.finalize_session_bindings(self, private)
473-
lapply(private$filter_states, function(x) x$finalize())
474-
invisible(NULL)
475466
}
476467
),
477468
# private fields ----
@@ -502,6 +493,19 @@ FilteredDataset <- R6::R6Class( # nolint
502493
# @return list of `FilterStates` objects.
503494
get_filter_states = function() {
504495
private$filter_states
496+
},
497+
498+
#' @description
499+
#' Object and dependencies cleanup.
500+
#'
501+
#' - Destroy inputs and observers stored in `private$session_bindings`
502+
#' - Finalize `FilterStates` stored in `private$filter_states`
503+
#'
504+
#' @return `NULL`, invisibly.
505+
finalize = function() {
506+
.finalize_session_bindings(self, private)
507+
lapply(private$filter_states, function(x) x$destroy())
508+
invisible(NULL)
505509
}
506510
)
507511
)

man/ChoicesFilterState.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/DFFilterStates.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/DataframeFilteredDataset.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/DateFilterState.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)