Idea: Isolate variables from cell dependencies #1706
-
This is similar to #298 In interactive notebooks, it would be useful to hold back expensive computation until all parameters are set. The user could then press a button to update the dependent cells. In R Shiny this is handled by "isolating" variables. Changing an isolated variable does not cause a reevaluation of the (reactive) variables that depend on them. (https://shiny.rstudio.com/articles/isolation.html) Would it be possible to do something similar in Pluto? In the example below I imagine that the (Bonus points if outdated cells can be highlighted)
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
A while ago a hacked together something that kind of does what I think you're wanting: macro isolate(var)
return :(getfield(current_module(), $(Meta.quot(var))))
end
function current_module()
id = PlutoRunner.moduleworkspace_count[]
ws = Symbol("workspace#$id")
return getfield(PlutoRunner.computer_workspace, ws)
end and then use with begin
update
n_dogs = @isolate(🐶)
n_cats = @isolate(🐱)
md"""
You have $(n_dogs) dogs and $(n_cats) cats!
"""
end Obviously it's a hack, but some official way to isolate variables like that would be nice. Maybe there's already a nice way to do this with the Disable cell feature? |
Beta Was this translation helpful? Give feedback.
-
The Wiki states that
Does this mean that a |
Beta Was this translation helpful? Give feedback.
-
The answers by @MichaelHatherly are great! Those should answer your question for now. I created a new discussion item with something that we have been discussing on the weekly pluto developers call (18:00 Thursday Berlin time, everyone is welcome!): #1743 |
Beta Was this translation helpful? Give feedback.
The Wiki states that
Does this mean that a
Ref()
can solve this?(I could not make it work by *randomly wrapping variables in
Ref()
🤷 )