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

Variables in a triggered reactive handler are reset to their initial value #64

Open
PGimenez opened this issue May 22, 2024 · 2 comments
Assignees

Comments

@PGimenez
Copy link
Member

The issue is that when a handler is triggered, only the variable attached to the handler has its value updated - all others are reset to the initial values. This only happens in GB, if you run the app from the REPL with Genie.loadapp() it works fine.

Here's a video describing the issue:
https://www.dropbox.com/t/9lPvnBmjVURgbQ9m

and the code to reproduce it:

using GenieFramework
@genietools

@app begin
    @out vowels=["a","b","c","d"]
    @in selected_vowels = ["a", "b"]
    @in N = 1.0
    @in trigger = false


    @onchange trigger begin
        println("Trigger clicked")
        @show selected_vowels
        @show N
    end

    @onchange selected_vowels begin
        println("Vowel selected")
        @show selected_vowels
        @show N
    end

    @onchange N begin
        println("Number picked")
        @show selected_vowels
        @show N
    end
end

ui() = [p("{{selected_vowels}}, {{N}}"),select(:selected_vowels, options=:vowels, var":multiple"="true"), slider(1:1:10,:N), btn("Trigger", @click("trigger = !trigger"))]
@page("/",ui)
@essenciary essenciary self-assigned this May 22, 2024
@essenciary
Copy link
Member

Updated codebase:

using GenieFramework
@genietools

@app begin
    @out vowels=["a","b","c","d"]
    @in selected_vowels = ["a", "b"]
    @in N = 1
    @in trigger = false
    @out message = "Hello, World!"


    @onchange trigger begin
        println("Trigger clicked")
        # selected_vowels = selected_vowels
        # N = N
        message = "Button clicked. N = $N, selected vowels = $selected_vowels"
    end

    @onchange selected_vowels begin
        println("Vowel selected")
        # selected_vowels = selected_vowels
        # N = N
        message = "Vowel selected. N = $N, selected vowels = $selected_vowels"
    end

    @onchange N begin
        println("Number picked")
        # selected_vowels = selected_vowels
        # N = N
        message = "Number picked. N = $N, selected vowels = $selected_vowels"
    end
end

ui() = [
  p("{{selected_vowels}}, {{N}}")
  p("{{message}}")
  select(:selected_vowels, options=:vowels, var":multiple"="true")
  slider(1:1:10,:N)
  btn("Trigger", @click("trigger = !trigger"))
]

@page("/", ui)

@essenciary
Copy link
Member

essenciary commented May 23, 2024

This is now fixed but with more of a hack fix in GenieBuilder. The actual problem seems to have been introduced in Stipple 0.28 but will require more time to debug.

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

2 participants