Skip to content
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

Allow only one subscription per affordance #356

Merged
merged 9 commits into from
Dec 13, 2021
Merged

Conversation

relu91
Copy link
Member

@relu91 relu91 commented Dec 2, 2021

This PR adds an additional step to observeProperty and subscribeEvent algorithms of the ConsumeThing. It forces the runtime implementation to check whether the affordance has already an active Subscription, and if it is the case the runtime must throw a NotAllowedError. This should make clear to implementers that it is not possible to subscribe multime times to the same affordance, but I also added an editor note to make it cristal clear.

The PR is currently in draft mode cause I wanted to use Set as type of the list of active Subscriptions/Observations but ECMA specification is not included among our xref and it conflicts with web-platform.

Note: It covers the points raised in #346.


Preview | Diff

@@ -1213,6 +1213,16 @@ <h4>Internal slots for ConsumedThing</h4>
<td>`null`</td>
<td>The <a>Thing Description</a> of the {{ConsumedThing}}.</td>
</tr>
<tr>
<td><dfn>[[\activeSubscriptions]]</dfn></td>
<td>`{}`</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a good idea to have an internal slot as a set, as it is usable with all policies (replace existing, reject if existing, add, ...).

index.html Outdated
@@ -1739,8 +1764,16 @@ <h3>The <dfn>subscribeEvent()</dfn> method</h3>
Takes as arguments |eventName:string|, |listener:WoTListener| and
optionally |onerror:ErrorListener| and |options:InteractionOptions|.
It returns a {{Promise}} to signal success or failure.
<p class="ednote">
This algorithm allow for only one active {{Subscription}} per <a>Event</a>. If a new
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we repeat this every time, or just say once for the whole API?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I think another good place to state this is in the Subscription section but I don't know if we want to keep this simple to possibly change it in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also omit the ednote, since the algorithm is clear enough.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?: this algorithm allowS ...

Copy link
Contributor

@zolkis zolkis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work, thanks!

Copy link
Contributor

@danielpeintner danielpeintner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering why this PR includes changes to
typescript/thing-description/schema/td-json-schema-validation.json
and
typescript/thing-description/thing-description.d.ts

The changes should be already there... sync with master ?

@relu91
Copy link
Member Author

relu91 commented Dec 13, 2021

Cleaned up commit history and added a fix for #358.

@relu91 relu91 marked this pull request as ready for review December 13, 2021 10:35
<tr>
<td><dfn>[[\activeObservations]]</dfn></td>
<td>`{}`</td>
<td>A {{Set}} containing the names of active {{Subscription}}'s for an <a>Property</a></td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it should read
a set of active Observations but then internal linking is no longer working.... maybe we can refer to it by id

index.html Outdated
@@ -1677,8 +1687,16 @@ <h3>The <dfn>observeProperty()</dfn> method</h3>
Takes as arguments |propertyName:string|, |listener:InteractionListener| and
optionally |onerror:ErrorListener| and |options:InteractionOptions|.
It returns a {{Promise}} that resolves on success and rejects on failure.
<p class="ednote">
This algorithm allow for only one active {{Subscription}} per <a>Property</a>. If a new
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?: this algorithm allowS ...

@danielpeintner
Copy link
Contributor

Scripting Call 2021-12-13
@relu91 fixes the 2 editorial issues and than we can merge

@relu91
Copy link
Member Author

relu91 commented Dec 13, 2021

@danielpeintner it should be ready to go :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants