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

Observables + usestate + useeffect stuck forever #17

Open
fonsp opened this issue Aug 6, 2024 · 0 comments
Open

Observables + usestate + useeffect stuck forever #17

fonsp opened this issue Aug 6, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@fonsp
Copy link
Member

fonsp commented Aug 6, 2024

In this notebook, the last cell is stuck running forever and can't be interrupted.

# ╔═╡ b0d2f6ee-53d9-11ef-1488-89e1652a0a68
using Observables

# ╔═╡ 5826d8f7-9aeb-438d-b426-ac166ab9800c
using PlutoHooks

# ╔═╡ dcc6a1e5-29ea-4f57-9bc6-cbaa923c0e2c
obs = Observable(0)

# ╔═╡ d2796325-fae8-4080-9178-35e115ee7cd7
zzz = let
	state, set_state = @use_state(obs[])

	Observables.on(set_state, obs)
	@use_effect([]) do
		
		return () -> Observables.off(set_state)
	end

	state
end

# ╔═╡ b7b29cef-bee6-4258-b411-968c0f1f9667
rand(zzz)

# ╔═╡ 5e6e0ef9-7387-469b-97a7-5d552e0f2eab
for i in 1:3
	sleep(1)
	obs[] = i
end

Found this while working on fonsp/Pluto.jl#2895

@fonsp fonsp added the bug Something isn't working label Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant