Skip to content

Commit c402d78

Browse files
authored
Merge pull request #73 from JuliaWeb/howtoplutofaster
docs: Make Pluto polling faster
2 parents 4065cee + b1c5967 commit c402d78

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

docs/src/howto.md

+13-16
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ In order to closely track the newest notebook state, you will need to tap into t
154154
You could write the following code in the pluto notebook that updates the module every second (if you have a better event-driven update solution, please raise an issue!).
155155

156156
```julia
157-
using PlutoLinks, PlutoHooks
157+
using PlutoLinks
158158

159159
using RemoteREPL, Sockets, UUIDs
160160

@@ -166,21 +166,18 @@ session_id = UUID("f03aec15-3e14-4d58-bcfa-82f8d33c9f9a")
166166

167167
con2server = connect_remote(Sockets.localhost, 27765; session_id=session_id)
168168

169-
takemodulesymbol() = Symbol("workspace#" ,PlutoRunner.moduleworkspace_count[])
170-
171-
let # update module in RemoteREPL every 1 sec
172-
count, set_count = @use_state(1)
173-
@use_task([]) do
174-
new_count = count
175-
while true
176-
sleep(1.0)
177-
new_count += 1
178-
set_count(new_count) # (this will trigger a re-run)
179-
end
180-
end
181-
mod = eval(takemodulesymbol())
182-
#@eval(@remoterepl $"%module $mod")
183-
remote_module!(mod)
169+
# update module in RemoteREPL when it changes in Pluto
170+
@use_task([]) do
171+
mod = :nothing_yet
172+
while true
173+
newval = Symbol("workspace#", Main.PlutoRunner.moduleworkspace_count[])
174+
if newval != mod
175+
mod = newval
176+
remote_module!(Core.eval(Main, mod))
177+
end
178+
179+
sleep(0.05)
180+
end
184181
end
185182
```
186183

0 commit comments

Comments
 (0)