-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
observeallproperties
and unobserveallproperties
methods are missing
#312
Comments
btw the spec does not even have |
We will wait until these operations are properly defined in the TD spec.
The same arguments are valid for subscribeallevents. |
I think |
Also, we need to get experience with how this is implemented in various bindings, and what kind of states are kept around for tracking. Like are these scenarios valid:
So far, based on what @danielpeintner said, only the first scenario should be valid, is that correct? And it means the underlying bindings can actually do this in a single operation, with no looping over all properties? Now the question that is more relevant for Scripting: should Scripting allow emulation (by implementation, e.g. node-wot) of observeall/unobserveall even though they are not exposed by a TD as single operations, but still available as scripting convenience? Based on what @danielpeintner said, this should not be the case. The problem with this is that an API contract published by a W3C spec has different expectations than an API contract exposed by a TD. In other words, if a developer calls thing.observeAllProperties(), it's kind of unintuitive to explain that it will fail if the TD does not have a single op to cover this, and why the implementation denies doing it by a loop, so now the developer will have to explicitly loop over all properties to subscribe to them. On the other hand, if we implement the internal looping for convenience, then the implementation might have to keep an internal state of how exactly subscriptions happened, so that it could consistently unwind/manage the subscriptions. In both cases we would deserve developer criticism, either from one viewpoint, or the other :). However, in W3C the advice is to favor the developers over the implementers. That would turn things towards the convenience side. Of course, we could include an option to observeall that if it's not doable by one op, should the implementation emulate it. But now even the API got more complex. It would be better if there was a simple policy that worked with a simple API. A lot to discuss, I guess. |
Something quite similar at w3c/wot-thing-description#1082 There @benfrancis said that Regarding convenience or not, I would say that it can be done later. For now, only if there is an |
OK, there the use case seems to be not only a convenience, but playing better with transactional interactions. However, as @relu91 mentioned, Scripting doesn't support writeall at the moment, since it has a lot of problems around semantics (like synchronization in general). For instance, if a script provides fewer properties/values to write than there is in the Thing, does it mean some properties have to be removed? Or should the operation fail? But the latter is complicated by the fact that the TD/ConsumedThing could only see a view on the original Thing (for privacy and security reasons). Is it possible that a writeall method overrides the structure of the remote end? That could be considered a security vector. Here with subscribeall and observeall, things are simpler and indeed we could play along the convenience argument. This whole problem actually exposes the fragility of mapping request-response APIs to functions... If we go with a function, then it has to work, either by one op, or by looping over multiple ops. The reason for this is that the developer has expressed intent to observe all properties. Therefore the implementation should do that, regardless if done by one (if possible) op or many: it's good if it can be optimized, but becomes an implementation detail, rather than a feature. We could also include an option to that function that it should fail if the single op is not available, but needs to be explicitly stated in the code, so the default value would meant to emulate (loop over all properties). Now the same argument applies to readall as well, and in principle to writeall as well (even though that is not supported, either). |
Even though I agree with most of the comments above, for me Scripting API works in a way that the developer has to read the TD properly beforehand. A developer can ignore looking at the forms in the interaction level but the forms on the Thing level, where all the |
IMHO the whole point of the Scripting API is to provide easier ways to access remote Things than looking into forms and all associated quirks (at which point the Fetch API is probably the best to use).
Why not, if the intent was anyway to observe all, and it can be trivially done (saving a lot of code lines for scripts), albeit by multiple requests? Either the developer or the implementation needs to do it. From a developer's perspective, if I have a function to observe all properties, I usually don't care if it had a TD op behind, i.e. the developer use case is "observe all properties: if you can do it with one request, good, otherwise take all it needs to do it". Then we have the option to expose a request-response API, which can list all available ops that can be used in a request and then tailor each request bound by generic constraints and particular ones. Then we have the option for an object-API, one @draggett proposed, which also makes the available ops enumerable, and callable like functions/ accessible like properties. Multiplicity would need specific functions, but so does our API. There if the op was supported, the function would be available, otherwise not (in the functional API, a function would always be there and fail if not supported, but see above). So my point is that we should respect developers' needs first, then implementers, then spec makers. We are not in the position to tell developers how to work around quirks, it's the other way around :). Having an observeall() method, it would be awkward to explain why does it fail, when observing individual properties doesn't fail. That would not be developer-friendly. But could be done, of course, in the name of perfect TD-ness. :) |
After thinking for a while, I think this is what I was always thinking of but I like your way of thinking more. I think it should be just made clear that both would be possible. This would apply to read/write all/multi properties too :) |
Scripting Call 2021-07-19
The decision was made to go with having
|
A similar TD issue about events has been closed by now (see w3c/wot-thing-description#1082). I opened w3c/wot-thing-description#1976 Please let me know whether it is good enough and conveys the information we require. |
The TD spec has the new operations of
observeallproperties
andunobserveallproperties
. However, these are not available in the Scripting API.See also eclipse-thingweb/node-wot#405
The text was updated successfully, but these errors were encountered: