3 ms·
My bad, I didn't really explain that part. In practice, when we receive a GUI event, we then modify something in our surrounding environment, usually some mode
by verdagon 5y ago
My bad, I didn't really explain that part.
In practice, when we receive a GUI event, we then modify something in our surrounding environment, usually some model, controller, or other view. To interact with any of those in Rust, we need to refer to it by some sort of ID.
This is the same ID you're referring to, which objects get when they're instantiated, at least for views (models and controllers likely do something similar).
My central question is: why would we want to serialize those IDs?
Also, WYSWYG might not be the best example, as it's a GUI that produces another GUI, hence some confusion. If you think about this in terms of a simple app that maintains a Customer database, you'll see what I mean; we wouldn't ever want to serialize a button click event there, especially since the hydrated IDs aren't stable and we don't know what they refer to unless we serialize the entire app UI state.
- b3morales 5y agoMaybe I'm missing something particular about Rust? When the archive is loaded at runtime, we don't need explicit IDs: we have a normal object graph, with references between things. The instantiated widgets have identity as objects in memory. The string `id="ykl-6F-b5r"` isn't relevant -- or used at all. You can create as many instances of `Button` as you want, and they are different, and their targets (the other widgets they message when tapped) are different because they were either created alongside or, if they were live before the archive was deserialized, a reference was made to them as part of the deserialization process.
- verdagon 5y agoI think what you might be missing is that, in (safe + idiomatic) Rust, we actually can't have references between things (unless we want to make our entire GUI immutable, which would be a tad silly). Since we can't use references, we need to "refer" to other objects via IDs.
- b3morales 5y agoThanks, I'll have to look into how GUIs in Rust work then; that sounds utterly bizarre to me :) I thought you could take references to things in Rust. Also, in particular, I don't understand why you'd want to use closures -- inherently reference-y -- when everything else is (I guess?) a non-reference plain value.