Skip to content

Commit 7868180

Browse files
authored
Merge pull request #41 from rstudio/session-auto-events
Add auto_events to ChromoteSession
2 parents a71e7a3 + c27f609 commit 7868180

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

R/chromote_session.R

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,18 @@ ChromoteSession <- R6Class(
2626
#' @param wait_ If `FALSE`, return a [promises::promise()] of a new
2727
#' `ChromoteSession` object. Otherwise, block during initialization, and
2828
#' return a `ChromoteSession` object directly.
29+
#' @param auto_events If `NULL` (the default), use the `auto_events` setting
30+
#' from the parent `Chromote` object. If `TRUE`, enable automatic
31+
#' event enabling/disabling; if `FALSE`, disable automatic event
32+
#' enabling/disabling.
2933
#' @return A new `ChromoteSession` object.
3034
initialize = function(
3135
parent = default_chromote_object(),
3236
width = 992,
3337
height = 744,
3438
targetId = NULL,
35-
wait_ = TRUE
39+
wait_ = TRUE,
40+
auto_events = NULL
3641
) {
3742
self$parent <- parent
3843

@@ -67,6 +72,7 @@ ChromoteSession <- R6Class(
6772
# Graft the entries from self$protocol onto self
6873
list2env(self$protocol, self)
6974

75+
private$auto_events <- auto_events
7076
private$event_manager <- EventManager$new(self)
7177
private$is_active_ <- TRUE
7278

@@ -165,7 +171,11 @@ ChromoteSession <- R6Class(
165171
},
166172

167173
get_auto_events = function() {
168-
self$parent$get_auto_events()
174+
if (!is.null(private$auto_events)) {
175+
private$auto_events
176+
} else {
177+
self$parent$get_auto_events()
178+
}
169179
},
170180

171181
debug_log = function(...) {
@@ -189,6 +199,7 @@ ChromoteSession <- R6Class(
189199
is_active_ = NULL,
190200
event_manager = NULL,
191201
pixel_ratio = NULL,
202+
auto_events = NULL,
192203
init_promise_ = NULL,
193204

194205
register_event_listener = function(event, callback = NULL, timeout = NULL) {

man/ChromoteSession.Rd

Lines changed: 7 additions & 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)