whamtet / simpleui

JS Free Single Page Applications
https://simpleui.io
Eclipse Public License 2.0
251 stars 15 forks source link

How to handle sibling components? #26

Closed telekid closed 1 year ago

telekid commented 1 year ago

How do you idiomatically handle components that appear as siblings in the stack? For example, if you have a Container component and a Pane component, and you want the container component to have two panes, what would you do to uniquely identify each pane?

I can see how you might hack around with map-indexed, but you can imagine situations where e.g. the Pane components are separated by something between them irregularly – that is, they aren't in a repeating pattern.

whamtet commented 1 year ago

In your example the system can only handle multiple panes if they are in an array. In that case the path to them will be

Container/0/Pane Container/1/Pane

You might not want an array, but in that case its easier to just keep everything in the same component. Remember that you can still separate out the UI components into ordinary functions etc. Does that answer the question?

whamtet commented 1 year ago

@telekid sorry for the initial delay in answering, I'm keen to help make ctmx clearer and would appreciate your feedback.

telekid commented 1 year ago

I think it does, yeah. Closing for now, will reopen if I run into this need a few more times.