Skip to content

Commit

Permalink
Merge pull request #2018 from JKRhb/event-vs-observable
Browse files Browse the repository at this point in the history
Add text regarding choosing between events and observable properties
  • Loading branch information
egekorkan authored May 28, 2024
2 parents 2cf0b1c + bf11854 commit 67b7c91
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1896,6 +1896,19 @@ <h3><code>EventAffordance</code></h3>
<code>unsubscribeevent</code> unless the protocol supports implicit unsubscription mechanisms (e.g.,
heartbeat to detect connection loss).
</p>
<p>
EventAffordances are similar to observable PropertyAffordances in the sense that the Thing itself informs
interested Consumers about state changes. However, a main difference of EventAffordances is that not every
change of the associated resource needs to trigger an event message to be emitted, e.g. a critical
threshold for a numeric value. Furthermore, EventAffordances allow for more complex subscribing and
unsubscribing mechanisms via the definition of <code>subscription</code>, <code>dataResponse</code>, and
<code>cancellation</code> DataSchema definitions. Not all protocols might support these more advanced
mechanisms, however, which is why in some scenarios, events may be very similar to observable
PropertyAffordances. In these cases, the choice between a Property and a Event for modelling the
Affordance should be made based on the semantics of the underlying resource; for example, if the state of
the affordance is also supposed to be read or written by a Consumer, then a Property is most likely the
appropriate choice.
</p>
</section>
<section>
<h3><code>VersionInfo</code></h3>
Expand Down
10 changes: 9 additions & 1 deletion validation/td-validation.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,15 @@
<code>unsubscribeevent</code>, or both terms within an
<a href="#dfn-array" class="internalDFN" data-link-type="dfn">Array</a>.</span></p><p class="note">
It is considered to be good practice that each <code>subscribeevent</code> has a corresponding <code>unsubscribeevent</code> unless the protocol
supports implicit unsubscription mechanisms (e.g., heartbeat to detect connection loss).</p>"""^^rdf:HTML .
supports implicit unsubscription mechanisms (e.g., heartbeat to detect connection loss).</p>
<p>
EventAffordances are similar to observable PropertyAffordances in the sense that the Thing itself informs interested Consumers about state changes.
However, a main difference of EventAffordances is that not every change of the associated resource needs to trigger an event message to be emitted, e.g. a critical threshold for a numeric value.
Furthermore, EventAffordances allow for more complex subscribing and unsubscribing mechanisms via the definition of <code>subscription</code>, <code>dataResponse</code>, and <code>cancellation</code> DataSchema definitions.
Not all protocols might support these more advanced mechanisms, however, which is why in some scenarios, events may be very similar to observable PropertyAffordances.
In these cases, the choice between a Property and a Event for modelling the Affordance should be made based on the semantics of the underlying resource; for example, if the state of the affordance is also supposed to be read or written by a Consumer, then a Property is most likely the appropriate choice.
</p>
"""^^rdf:HTML .

:MultiLanguageShape a sh:NodeShape ;
sh:targetClass td:MultiLanguage ;
Expand Down

0 comments on commit 67b7c91

Please sign in to comment.