Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💁📩 Support publish_to_js inside logs #2607

Merged
merged 2 commits into from
Jul 17, 2023
Merged

Conversation

fonsp
Copy link
Owner

@fonsp fonsp commented Jul 16, 2023

Fix #2092

I had to change the dynamics of publish_to_js, but these changes will be done anyways by #2162 : the published object will be stored during the render to JavaScript, not during the call of publish_to_js. (But when using it inside HypertextLiteral, this is the same. Actually it's hard to think of a case where it is not the same.)

@github-actions
Copy link
Contributor

Try this Pull Request!

Open Julia and type:

julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/fonsp/Pluto.jl", rev="publish_to_js-inside-logs")
julia> using Pluto

@fonsp
Copy link
Owner Author

fonsp commented Jul 16, 2023

Test notebook:

# ╔═╡ ab8f6d4d-7cf2-4836-89ec-2b110388b448
using HypertextLiteral

# ╔═╡ 28c70a43-cee6-462c-90ee-697a04882ecf
test_slow(x) = @htl """
<script>
let out = html`<div>random_text!</div>`
let test = setTimeout(() => {
console.log($(PlutoRunner.publish_to_js(x)))
}, 100)
return out
</script>
"""

# ╔═╡ 7be25bf1-d9db-4e64-9f63-1a1cfee84148
test(x) = @htl """
<script>
let out = html`<div>random_text!</div>`
let data = $(PlutoRunner.publish_to_js(x))
out.innerText = data
return out
</script>
"""

# ╔═╡ b723da9f-2d4b-456c-844a-0ed572ff9f56


# ╔═╡ 1172d9c0-b55a-4e1f-ad95-75c9bfe20d0c
@info test(123)

# ╔═╡ b6ccc229-4beb-4a11-b7f7-cde6b402ac4d
# test(rand(10))

# ╔═╡ 5144f698-e076-40b6-9e59-d642504be158
begin
	@info test(rand(10)) test(rand(10))
	sleep(.2)
	test(2)
end

# ╔═╡ 658f45c5-6fc8-428c-a0ea-1fd564aa766c
merge!(Dict(), Dict(1=>2))

@fonsp
Copy link
Owner Author

fonsp commented Jul 16, 2023

It fixes #2092!

image

@fonsp fonsp merged commit c569adf into main Jul 17, 2023
16 checks passed
@fonsp fonsp deleted the publish_to_js-inside-logs branch July 17, 2023 08:19
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.

publish_to_js mostly breaks if used inside logs
1 participant