Skip to content

Commit 80722b1

Browse files
refactor: update prose and IDL based on discussion
1 parent b01af6e commit 80722b1

File tree

2 files changed

+33
-25
lines changed

2 files changed

+33
-25
lines changed

index.html

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,53 +1285,61 @@ <h2>The <dfn>ActionInteractionOutput</dfn> interface</h2>
12851285
Note: The output of a synchronous action MAY be limited to the functionality of a regular {{InteractionOutput}} object, e.g., invoking the `cancel()` method might not have an effect.
12861286
</p>
12871287
<p>
1288-
This interface exposes an action status object. Its implementation
1289-
will allow cancelling asynchronous actions and report the status of a long running action.
1288+
This interface exposes functions which
1289+
will allow cancelling asynchronous actions and query the status of a long running action.
12901290
</p>
12911291
<pre class="idl">
1292-
enum ActionStatus {
1293-
"running",
1294-
"success",
1295-
"error"
1296-
};
1297-
12981292
[SecureContext, Exposed=(Window,Worker)]
12991293
interface ActionInteractionOutput : InteractionOutput {
1300-
readonly attribute object? error;
1301-
Promise&lt;ActionStatus&gt; status();
1302-
Promise&lt;undefined&gt; cancel();
1294+
Promise&lt;InteractionOutput&gt; query(
1295+
optional InteractionInput params = {},
1296+
optional InteractionOptions options = {});
1297+
Promise&lt;undefined&gt; cancel(
1298+
optional InteractionInput params = {},
1299+
optional InteractionOptions options = {});
1300+
// Note: retrieving the result of an action via the implicit InteractionOutput interface
1301+
// will only work after the action has been completed
13031302
};
13041303
</pre>
1305-
<p>
1306-
The <dfn>error</dfn> property represents a possible error, initially `null`.
1307-
</p>
1308-
<p class="ednote" title="Should state be a function or an attribute only?">
13091304

13101305
</p>
1311-
<p class="ednote" title="Additional action object functions needed?">
1312-
Should we allow pause/resume also? TD has no notion of it.
1313-
</p>
1314-
<section><h3>The <dfn>status()</dfn> function</h3>
1315-
Reports the status of an <a>Action</a> (one of <code>running</code>, <code>success</code>, or <code>error</code>), or rejects on error. The method MUST run the following steps:
1306+
1307+
<section><h3>The <dfn>query()</dfn> function</h3>
1308+
Reports the status of an <a>Action</a>, or rejects on error. The method MUST run the following steps:
13161309
<ol>
13171310
<li>
13181311
Return a {{Promise}} |promise:Promise| and execute the next steps
13191312
[=in parallel=].
13201313
</li>
13211314
<li>
1322-
TODO
1315+
If invoking this method is not supported (e.g., synchronous action)
1316+
[=reject=] |promise| with a {{NotSupportedError}} and stop.
1317+
</li>
1318+
<li>
1319+
Let |res| be the result of making a request to the underlying platform (via the <a>Protocol Bindings</a>) to query the <a>Action</a> status given optional |params| and |options|. If quering |res| fails, [=reject=] |promise| with {{OperationError}} and stop.
1320+
</li>
1321+
<li>
1322+
[=Resolve=] |promise| with |res|.
13231323
</li>
13241324
</ol>
13251325
</section>
13261326
<section><h3>The <dfn>cancel()</dfn> function</h3>
1327-
Cancels a running WoT <a>Action</a> or rejects on error. The method MUST run the following steps:
1327+
Cancels a running WoT <a>Action</a>, or rejects on error. The method MUST run the following steps:
13281328
<ol>
13291329
<li>
13301330
Return a {{Promise}} |promise:Promise| and execute the next steps
13311331
[=in parallel=].
13321332
</li>
1333-
<li>
1334-
TODO ... applicable when the state is running
1333+
<li>
1334+
If invoking this method is not supported (e.g., synchronous action)
1335+
[=reject=] |promise| with a {{NotSupportedError}} and stop.
1336+
</li>
1337+
<li>
1338+
Make a request to the underlying platform (via the <a>Protocol Bindings</a>) to cancel the <a>Action</a> given optional |params| and |options|.
1339+
If cancelling fails, [=reject=] |promise| with {{OperationError}} and stop.
1340+
</li>
1341+
<li>
1342+
[=Resolve=] |promise|</a>.
13351343
</li>
13361344
</ol>
13371345
</section>

typescript/scripting-api/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ declare namespace WoT {
9393
query(params?: InteractionInput, options?: InteractionOptions): Promise<InteractionOutput>
9494
// cancel a pending/running action
9595
cancel(params?: InteractionInput, options?: InteractionOptions): Promise<void>
96-
// Note: retrieving the result of the action via implicit InteractionOutput interface will only work after the action has been completed
96+
// Note: retrieving the result of an action via the implicit InteractionOutput interface will only work after the action has been completed
9797
}
9898

9999
export interface Subscription {

0 commit comments

Comments
 (0)