Skip to content

Commit

Permalink
feat: add property observation to example file
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Jan 18, 2022
1 parent 4f1bfb8 commit 9398f4e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions example/dart_wot_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ final thingDescriptionJson = '''
},
"properties": {
"status": {
"observable": true,
"forms": [
{
"href": "/.well-known/core"
},
{
"href": "/hello",
"op": ["observeproperty", "unobserveproperty"]
}
]
},
Expand Down Expand Up @@ -84,6 +89,15 @@ Future<void> main() async {
final value2 = await status2.value();
print(value2);

Subscription? subscription;

// TODO(JKRhb): Turn into a "real" observation example.
subscription = await consumedThing.observeProperty("status", (data) async {
final value = await data.value();
print(value);
await subscription?.stop();
});

final fetchedThingDescription = await fetchThingDescription(
"https://raw.githubusercontent.com/w3c/wot-testing/b07fa6124bca7796e6ca752a3640fac264d3bcbc/events/2021.03.Online/TDs/Oracle/oracle-Festo_Shared.td.jsonld",
servient);
Expand Down

0 comments on commit 9398f4e

Please sign in to comment.