-
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
New op values (cancelaction, queryaction,and queryallactions) #335
Comments
I had a chat with @egekorkan and I would like to describe how he sees the relation between TD and Scripting API w.r.t. cancelling/querying actions.
I'm looking forward to comments! |
Thanks for noting this down! I think it represents my thoughts really well. I had opened w3c/wot-thing-description#1408 after this discussion. Just to avoid some misconceptions:
|
The "async" terminology is not correct, as all actions are async (on the network). A better name is needed. As for scripting API design, the action id would be a new thing, but if we want separate op's for
If a script doesn't want to cancel or query the status, could right away call But then the same
In summary, yes, separate methods + id seem to be the cleanest design. |
I would be open for other names. Just a precision on the following comment:
An action can be queried even if it is synchronous. It is relatively easy to implement a 10 second lasting response handler in a backend library so the consumer can query it in the meantime. The async flag does not indicate whether an action is queriable or not. |
Even if an action appears to be synchronous, it is asynchronous, and if it can be queried, just proves it's async. :). |
Sort of but I think before future discussion, what I mean by these words is what I have illustrated (literally) at w3c/wot-thing-description#890 . I would be open for alternatives |
On the call on 7. March several use cases for actions were discussed:
In addition to the use cases, various policies are possible as well, for instance:
@danielpeintner @ashimura @egekorkan @relu91 @JKRhb @k-toumura please complete/edit these |
The question is, can we design an API that would support all these variations in use cases and policies. Generic alternatives were discussed above, were the conclusion was we need the design with separate However, we could extend invoking an action with more options, and support action id's, even if the TD spec doesn't (yet) support them (since the implementations can always generate an id). Instead of returning an id, we could also use a returned object instead, which is more future-proof. Promise<ActionControl> invokeAction(DOMString actionName, // could also return a tuple
optional InteractionInput params = null,
optional InteractionOptions options = null);
Promise<undefined> cancelAction(DOMString actionName,
optional InteractionInput params = null, // contains the id
optional InteractionOptions options = null); // or data could contain the id
Promise<InteractionOutput> queryAction(DOMString actionName,
optional InteractionInput params = null, // contains the id
optional InteractionOptions options = null); // or data could contain the id
[SecureContext, Exposed=(Window,Worker)]
interface ActionControl {
readonly attribute Promise<InteractionOutput> result;
readonly attribute USVString id;
}; Alternatively, Note that the const ac = await thing.invokeAction("temperature", { units: "Celsius" });
const id = ac.id;
var output = await ac.result; or directly var output = await (await thing.invokeAction("temperature", { units: "Celsius" })).result; |
I like the proposal. Just that I think it might be too early to define something like a |
2 comments (which do not affect the proposal itself)
|
FYI: besides |
I know that Do you see it differently @egekorkan ? Hence I propose to add the label:wait-for-td |
I agree that it is underspecified and we can indeed wait for the TD TF to resolve this first. The parts that are underspecified are mentioned above but to summarise:
Of course once those are specified by the TD, the way they are exposed in the scripting level needs a separate discussion. |
The corresponding TD issue is w3c/wot-thing-description#1408. |
There is a WIP PR, see w3c/wot-thing-description#1208
Once baked into the TD document we might need to discuss the consequences for the Scripting API.
The text was updated successfully, but these errors were encountered: