Replies: 1 comment 1 reply
-
Hi! Thank you for creating the discussion. I've taken a look at the builder approach you use. It's quite a lot of code and it also implements a rather complex typestate. I don't have experience with WoT, so my response is based on a quick review of the code you provided. For example, your builder makes the If you'd like to get a better idea of bon's builders' design and what its limits are, I recommend you to check the bon's Typestate API guide. Other than that, I see that your builder provides a configuration of sub-objects via closures that accept builders. E.g.: Thing::builder("...")
.property("first-property", |prop_builder| {
prop_builder
.finish_extend_data_schema()
.observable(true)
.bool()
}) It's also possible to achieve this with bon using custom methods, but there isn't a shorter attribute syntax to express that. I believe such API may be cumbersome to use in more advanced cases. There is some discussion about it at #127. The gist of it is that this pattern has the following problems:
In general, I think You might also want to take a look at state-shift, which may be the boilerplate reducer for advanced typestate handling. However, feel free to use If you have any more questions, you may ask them here on in bon's discord. |
Beta Was this translation helpful? Give feedback.
-
wot-td has a fairly complex builder.
Since the W3C Web of Things ThingDescription can be extended in various ways, the main Thing struct is generic on a set of traits and an heterogeneous list is used to allow to extend the struct as you build it.
Since with WoT 2.0 will require quite a number of changes I'm wondering if
bon
can deal with the pattern we are using so preparing branches with proposed changes wouldn't be more straightforward.Beta Was this translation helpful? Give feedback.
All reactions