Skip to content

Use bindingIsActive#1031

Merged
renkun-ken merged 1 commit intoREditorSupport:masterfrom
renkun-ken:active-binding
Mar 10, 2022
Merged

Use bindingIsActive#1031
renkun-ken merged 1 commit intoREditorSupport:masterfrom
renkun-ken:active-binding

Conversation

@renkun-ken
Copy link
Member

@renkun-ken renkun-ken commented Mar 10, 2022

What problem did you solve?

Related: #1030

This PR uses bindingIsActive(sym, env) to check if a symbol is active binding. It is a walk around of rlang::env_binding_are_active when base already does it.

(If you have)Screenshot

(If you do not have screenshot) How can I check this pull request?

makeActiveBinding("x", function() {
  cat("x\n")
  runif(1)
}, globalenv())

Run other commands and see if the workspace viewer correctly shows x as an active binding.

env <- local({
  makeActiveBinding("x", function() {
    cat("x\n")
    runif(1)
  }, environment())
  environment()
})
View(env)

@renkun-ken renkun-ken requested a review from MilesMcBain March 10, 2022 02:38
@MilesMcBain
Copy link
Collaborator

Does this still have an issue since rlang::env_binding_are_lazy(env, all_names) will evaluate the active bindings also?

@renkun-ken
Copy link
Member Author

Yes, rlang::env_binding_are_lazy(env, all_names) still will evaluate active bindings. So this PR does not resolve the problem but only replaces rlang function with base when possible.

@renkun-ken renkun-ken merged commit 91e9c06 into REditorSupport:master Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants