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

Allow updates with the same value #39

Closed
shashi opened this issue Jan 3, 2018 · 2 comments · Fixed by #149
Closed

Allow updates with the same value #39

shashi opened this issue Jan 3, 2018 · 2 comments · Fixed by #149

Comments

@shashi
Copy link
Member

shashi commented Jan 3, 2018

Right now the "counter" examples are broken since updating with the same value drops the update.

@JobJob
Copy link
Member

JobJob commented Jan 3, 2018

Changing this will require serious thinking about (multi-)client-server state syncing - I think leaving it as is so that only a changed value triggers the handlers might be the most practical. This is what Vue does afaict.

The count examples can be changed to:

function counter(start=0)
    w = Widget()

    # updates to this update the UI
    count = Observable(w, "count", start)
    onjs(count,
         WebIO.@js x->this.dom.querySelector("#count").textContent = x)

    # button clicks send changes to Julia via the `count` observable,
    # we print its current value to stdout
    on(count) do c
        println("count changed to $(count[])")
    end

    btn(label, d) = dom"button"(label,
                                events=Dict("click" => WebIO.@js () -> $count[] = $count[] + $d))

    w(
      dom"div"(
        btn("increment", 1),
        btn("decrement", -1),
        dom"div#count"(string(count[])),
      )
    )
end

@shashi
Copy link
Member Author

shashi commented Jun 27, 2018

I think handling multiple clients is a separate issue, something like #139 ?

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 a pull request may close this issue.

2 participants