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

UI element not updating #114

Open
gdkrmr opened this issue Jul 24, 2024 · 1 comment
Open

UI element not updating #114

gdkrmr opened this issue Jul 24, 2024 · 1 comment

Comments

@gdkrmr
Copy link

gdkrmr commented Jul 24, 2024

In the little app below, s1 sets the upper limit of s2, but the label on the second slider does not update when the position of s2 gets changed through s1.

I have tried notifying s2 separately but it didn't work.

App() do session::Session
    s1 = Slider(0:0.01:1)
    l1 = Labeled(s1, s1.value)
    s2 = Slider{Float64}(@lift(collect(0:0.01:$s1)),
                         Observable(0.0),
                         Observable(1),
                         Dict{Symbol, Any}())
    l2 = Labeled(s2, s2.value)
    return DOM.div(l1, l2)
end
@gdkrmr
Copy link
Author

gdkrmr commented Jul 24, 2024

I have figured out how to work around it. values, value and index are Observables but they only depend setindex!(::Slider) and don't update each other. Do you think Slider should be robust in these cases?

testapp = App() do session::Session                 
    s1 = Slider(0:0.01:1)                           
    l1 = Labeled(s1, s1.value)                      
    s2 = Slider{Float64}(@lift(collect(0:0.01:$s1)),
                         Observable(0.0),           
                         Observable(1),             
                         Dict{Symbol, Any}())       
    l2 = Labeled(s2, s2.value)                      
    on(s1) do _                                     
        s2[] = s2.value[]                           
    end                                             
    return DOM.div(l1, l2)                          
end                                                 

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

No branches or pull requests

1 participant