question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove `Stipple.init(m::M, ...)` and document workflow (`isready` and other app events)

See original GitHub issue

Hi again 😃 I just noticed this strange behaviour when initializing a ReactiveModel. When I call the init()-Function before altering values in the Struct, the values are visible on the backend side but they are not transferred to the remote Endpoint and are thus stuck on the default values. But if I first create the Struct and set the values and afterwards call the init()-Function, the values are overwritten again and the default values are in place (I have found both ways in the demos).

Expected Behaviour

Initialize a model with Stipple.init() -> change values in the back end -> see changes in the front end

Code Example

using Genie, Stipple, StippleUI

@reactive mutable struct Test <: ReactiveModel
    changed::R{Bool} = false
end

function changeModel(pModel)
    pModel.changed[] = true
    return pModel
end

function initFirst()
    model = Stipple.init(Test())
    return changeModel(model)
end

function initLast()
    model = changeModel(Test())
    return Stipple.init(model)
end


a = initFirst()
b = initLast()

println(a.changed[])
println(b.changed[])



function ui(model)
    page(model, class = "container", [
        p(
            span("", @text(:changed))
        )
    ]) |> html
end

route("/a") do 
    ui(a)
end
route("/b") do 
    ui(b) 
end 

up(8020, open_browser=true)

Am I missing something here or approaching this from the wrong angle?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
essenciarycommented, Mar 16, 2022

I can work on it - I’m struggling to make the session ModelStorage work, for some reason the session state gets pushed to all channels/clients.

0reactions
essenciarycommented, Mar 25, 2022

Currently releasing/tagging new versions. Working super smoothly (sorry, compilation was a bit slow, my CPU was loaded 😄 )

2022-03-25 20 09 13

Code:

using Stipple, StippleUI

@reactive! mutable struct Test <: ReactiveModel
    changed::R{Bool} = false
    sweetVec::R{Vector} = []
end

function changeModel!(model)
    model.changed[] = true
    model.sweetVec[] = ["ab", "cd", "ef", "gh"]

    model
end

function handlers(model)
    on(model.isready) do isready
        isready || return
        changeModel!(model)
    end

    on(model.changed) do val
      @show val
      notify(model, "The model has changed")
    end

    model
end

function ui(model::Test)
    page(model, class = "container", row(cell(class = "st-module", [
        toggle("Changed", :changed)
        list("", :bordered, :separator, style = "max-width: 25vw",
            [item("Hello {{ sweetVec[$(i-1)] }} ", :clickable, :v__ripple) for i in 1:length(model.sweetVec[])]
        )
        separator()
        list("", :bordered, :separator, style = "max-width: 25vw",
            [item("World {{ vec }}", @recur("vec in sweetVec"), :clickable, :v__ripple)]
        )
    ])), @iif(:isready)) |> html
end

route("/") do 
    ui(init(Test, transport = Genie.WebChannels) |> handlers)
end

up(8020, open_browser = true)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Stipple LifeCycle - Guides - Genie Framework Documentation
life-cycle and the various events of a Stipple app · 1. Sync request – server side response · 2. Client side rendering ·...
Read more >
Untitled
Captadores bartolini mk2, Appinit dlls registry key. Eastern coalfield limited recruitment 2012, First newspaper in america, Ipv6 localhost http, ...
Read more >
Untitled
Lg circle case review, Au coeur de l'urgence pompier marseille, Moonglade kennels, Security cam app ipad. Theology of the cross paul?
Read more >
Untitled
Kevin gates again sharebeast, Frauen werden gedeckt, Divalproex sodium 250 mg side effects, Sportive events 2013. Crankset 44t 170mm!
Read more >
pyglet Documentation - Read the Docs
To let pyglet respond to application events such as the mouse and ... data for vertex buffer objects, texture data, polygon stipple data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found