setzer22 / egui_node_graph

Build your node graph applications in Rust, using egui
MIT License
715 stars 134 forks source link

Add `UserState` to `build_node` #46

Closed setzer22 closed 2 years ago

setzer22 commented 2 years ago

Sometimes the NodeTemplate cannot store all the information you need to create a new node (may be too expensive to copy all that data around, or simply can't own the data). In those cases, it makes sense to store some sort of id or handle inside the NodeTemplate and use that to index into a structure holding the actual data.

To enable this pattern, the user_state is now passed as a parameter to build_node. This is a breaking change, but not a huge one: Old implementations can simply ignore the new parameter, and the compiler should guide users to the issue when updating. It still was deemed necessary because there's no other way to access graph-global data in build_node.