diff --git a/index.html b/index.html index f0968a47..55e8dd45 100644 --- a/index.html +++ b/index.html @@ -414,9 +414,6 @@

The WOT namespace

  • If invoking this method is not allowed for the current scripting context for security reasons, reject |promise| with a {{SecurityError}} and abort these steps.
  • -
  • - Run the validate a TD steps on |td|. If that fails, reject |promise| with {{SyntaxError}} and abort these steps. -
  • Let |thing:ConsumedThing| be a new {{ConsumedThing}} object constructed from |td|.
  • @@ -432,6 +429,12 @@

    The WOT namespace

    Resolve |promise| with |thing|. +

    + Note the difference between constructing ConsumedThing and using + the consume() method: the latter also initializes the protocol + bindings, whereas a simple constructed object will not have WoT Interactions + initialized until they are invoked. +

    @@ -1053,6 +1056,10 @@

    Constructing ConsumedThing

    To create {{ConsumedThing}} with the {{ThingDescription}} |td:ThingDescription|, run the following steps:
      +
    1. + Run the validate a TD steps on |td|. If that fails, + [= exception/throw =] {{SyntaxError}} and abort these steps. +
    2. Run the expand a TD steps on |td|. If that fails, re-[= exception/throw =] the error and abort these steps.
    3. @@ -1696,7 +1703,7 @@

      ConsumedThing Examples

      } catch (e) { console.log("TD fetch error: " + e.message); }; - + try { // subscribe to property change for “temperature” await thing.observeProperty("temperature", async (data) => { @@ -1722,13 +1729,13 @@

      ConsumedThing Examples

      } 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) { @@ -1813,10 +1820,10 @@

      ConsumedThing Examples

      // 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);