Explanation of this PR? #624
-
Hi, thanks for keeping discussions open and actively responding. Floem has some really nice looking UI. I was wondering about this PR, which is titled "ECS." I don't know much about ECS, only the basics of what it is, so can you explain why this is ECS? Does the .style on tuples have something to do with it? I'm wondering where you got the inspiration for both the VIEW_STORAGE and .style on tuple things from. VIEW_STORAGE to me looks like un-Rusty design, since most people say avoid statics and RefCells (I think). Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
ECS in this case isn't as strict of a system as other ecs systems are. In this case the ECS in that PR is referencing how views are owned by floem and they are identified and interacted with by unique ids. avoiding statics is a general recommendation that isn't specific to rust. It's not that statics are bad, just that they are overused. For people new to Rust, it would be easy to over use RefCell to get around the borrow checker. But it exists for a reason and they are useful when they provide the behavior that you want. |
Beta Was this translation helpful? Give feedback.
We use
.style()
on all types thatimpl IntoView
not just tuples. Styles are how we modify most/all of the properties of views.We still have h_stack and v_stack methods for building stacks, the difference between them is just the style though of
flex_row
vsflex_col
which makes sense as we use taffy for layout and that is all that is required to go from a h_stack to a v_stack.Using statics that are thread local allows us to build views and send updates to those views by their id's without needing to pass a context around in your app. Instead updates can be pushed to a static and processed by floem.