Skip to content

feat!: remove constructor from ConsumedThing interface #517

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

Merged
merged 3 commits into from
Nov 20, 2023
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
26 changes: 7 additions & 19 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -585,12 +585,6 @@

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.


Expand Down Expand Up @@ -1378,7 +1372,6 @@

The ConsumedThing interface

[SecureContext, Exposed=(Window,Worker)]
interface ConsumedThing {
constructor(ThingDescription td);
Promise<InteractionOutput> readProperty(DOMString propertyName,
optional InteractionOptions options = {});
Promise<PropertyReadMap> readAllProperties(
Expand Down Expand Up @@ -1476,7 +1469,7 @@

Internal slots for {{ConsumedThing}}


Constructing ConsumedThing

Creating ConsumedThing

After fetching a
Thing Description as a JSON object, one can create a
Expand Down Expand Up @@ -2654,21 +2647,21 @@

Internal slots for ExposedThing


Constructing {{ExposedThing}}

Creating {{ExposedThing}}

The {{ExposedThing}} interface extends {{ConsumedThing}}. It
is constructed from a full or partial {{ThingDescription}} object.
The {{ExposedThing}} interface
is created from a full or partial {{ThingDescription}} object.

Note that an existing {{ThingDescription}} object can be optionally modified (for instance by adding or removing elements on its |properties|, |actions| and |events| internal properties) and the resulting object can used for constructing an
Note that an existing {{ThingDescription}} object can be optionally modified (for instance by adding or removing elements on its |properties|, |actions| and |events| internal properties) and the resulting object can used for creating an
{{ExposedThing}} object. This is the current way of adding and
removing Property, Action and Event definitions, as illustrated in the examples.

Before invoking expose(), the {{ExposedThing}} object does not serve any requests. This allows first constructing {{ExposedThing}} and then initialize its Properties and service handlers before starting serving requests.
Before invoking expose(), the {{ExposedThing}} object does not serve any requests. This allows first creating {{ExposedThing}} and then initialize its Properties and service handlers before starting serving requests.

To construct an {{ExposedThing}} with the {{ExposedThingInit}}
To create an {{ExposedThing}} with the {{ExposedThingInit}}
|init:ExposedThingInit|, run the following steps:
  1. Expand Down Expand Up @@ -4299,11 +4292,6 @@

    API design rationale

    parsed JSON object that has been validated according to the [[[WOT-TD]]] specification.

    Factory vs constructors

    The factory methods for consuming and exposing Things are asynchronous and fully validate the input TD. In addition, one can also construct {{ConsumedThing}} and {{ExposedThing}} by providing a parsed and validated TD. Platform initialization is then done when needed during the WoT interactions.

    Observers

    Earlier drafts used the
    Expand Down