Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,6 @@ <h2>The <dfn>WOT</dfn> namespace</dfn></h2>
<li>
If invoking this method is not allowed for the current scripting context for security reasons, reject |promise| with a {{SecurityError}} and abort these steps.
</li>
<li>
Run the <a>validate a TD</a> steps on |td|. If that fails, reject |promise| with {{SyntaxError}} and abort these steps.
</li>
<li>
Let |thing:ConsumedThing| be a new {{ConsumedThing}} object constructed from |td|.
</li>
Expand All @@ -432,6 +429,12 @@ <h2>The <dfn>WOT</dfn> namespace</dfn></h2>
Resolve |promise| with |thing|.
</li>
</ol>
<p class="ednote">
Note the difference between constructing <a>ConsumedThing</a> and using
the <code>consume()</code> method: the latter also initializes the protocol
bindings, whereas a simple constructed object will not have <a>WoT Interactions</a>
initialized until they are invoked.
</p>
</div>
</section>

Expand Down Expand Up @@ -1053,6 +1056,10 @@ <h4>Constructing <code>ConsumedThing</code></h4>
To create {{ConsumedThing}} with the {{ThingDescription}}
|td:ThingDescription|, run the following steps:
<ol>
<li>
Run the <a>validate a TD</a> steps on |td|. If that fails,
[= exception/throw =] {{SyntaxError}} and abort these steps.
</li>
<li>
Run the <a>expand a TD</a> steps on |td|. If that fails, re-[= exception/throw =] the error and abort these steps.
</li>
Expand Down Expand Up @@ -1696,7 +1703,7 @@ <h2>ConsumedThing Examples</h2>
} catch (e) {
console.log("TD fetch error: " + e.message);
};

try {
// subscribe to property change for “temperature”
await thing.observeProperty("temperature", async (data) => {
Expand All @@ -1722,13 +1729,13 @@ <h2>ConsumedThing Examples</h2>
} catch (e) {
console.log("Error starting measurement.");
}

setTimeout(async () => {
try {
const temperatureData = await thing.readProperty("temperature")
const temperature = await temperatureData.value();
console.log("Temperature: " + temperature);

await thing.unsubscribe("ready");
console.log("Unsubscribed from the ‘ready’ event.");
} catch (error) {
Expand Down Expand Up @@ -1813,10 +1820,10 @@ <h2>ConsumedThing Examples</h2>
// Example of streaming processing: counting json objects
let objectCounter = 0
const parser = new Parser() //User library for json streaming parsing (i.e. https://github.com/uhop/stream-json/wiki/Parser)

parser.on('data', data => data.name === 'startObject' && ++objectCounter);
parser.on('end', () => console.log(`Found ${objectCounter} objects.`));

const response = await thing.readProperty(“eventHistory”)
await response.data.pipeTo(parser);

Expand Down