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.

[Question] Accessing Model sub-structures

See original GitHub issue

Hello! Let me begin by thanking you for the amazing framework, I started playing with Stipple two days ago and I find it rather pleasant to use (except for the lack of docstrings, but well, that’s life).

I am trying to develop a fairly complex dashboard to monitor my simulations, and would like to split my model, which otherwise will have more than 100 fields, into several sub-structures for code clarity and maintainability/sanity.

However, I need to be able to read/set those fields from some UI elements like Selector, Checkboxes or plot them.

Is it possible to turn something like

Base.@kwdef mutable struct Model <: ReactiveModel
  group1_field1::R{Bool} = true
  group1_field2::R{Bool} = true
  group1_field3::R{Bool} = true
 
  group2_field1::R{Bool} = true
  group2_field2::R{Bool} = true
  group2_field3::R{Bool} = true

...
end

model = Stipple.init(Model())

function ui()
  [dashboard(vm(model),class = "container",title = "My thingy",[
        heading("Group1"),
           checkbox("Field1", : group1_field1),
           checkbox("Field2", : group1_field2),
           checkbox("Field3", : group1_field3),
        heading("Group2"),
           checkbox("Field1", : group2_field1),
           checkbox("Field2", : group2_field2),
           checkbox("Field3", : group2_field3),
  ])]
end

into something like

Base.@kwdef mutable struct ModelGroup
  field1::R{Bool} = true
  field2::R{Bool} = true
  field3::R{Bool} = true
end

Base.@kwdef mutable struct Model <: ReactiveModel
  group1::R{ModelGroup} = ModelGroup(true, true, false)
  group2::R{ModelGroup} = ModelGroup(true, true, false)
end

and still use it from the ui?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:27 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
hhaenselcommented, Apr 13, 2021

It’s done and, as far as I can see, works like a charm. See also my post in PR 43. So now we have

Reactive(v::T) where T = convert(Reactive{T}, v)
r = Reactive([1, 2, 3])
on(r) do r
  @show(r)
end
#non-notifying
r[][3] = 4
#notifying
r[3] = 4
1reaction
essenciarycommented, Apr 12, 2021

For me it’s still not clear what Dicts are we talking about. Is this about Stipple.render?

I believe it’s useful to brainstorm features and improvements as they pop-up in different contexts, but to address them properly we should set separate issues for each individual topic with a well defined problem and a minimal working example.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Leveraging Frequent Query Substructures to Generate ...
In this paper, we propose SubQG, a new query generation approach based on frequent query substructures, which helps rank the existing (but ...
Read more >
How do I create and use Sub Structures to filter my model?
Sub Structures can be useful to filter drawings and reports, create smaller views, design certain members ... Access the Report ribbon; Click Model...
Read more >
Optimal Substructure Property in Dynamic Programming
A given problem is said to have Optimal Substructure Property if the optimal solution of the given problem can be obtained by using...
Read more >
Access List inside model - asp.net mvc
This model holds all data to be shown in the View and is created by the Controller.
Read more >
Recognizing Protein Substructure Similarity Using Segmental ...
First, the conserved structure pieces excised from different protein structures can be directly used to assemble new protein structure models in approaches such ......
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