Skip to content

Commit 81b23e6

Browse files
committed
fixup! Implement ExposedThing functionality
1 parent a748279 commit 81b23e6

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

lib/src/core/implementation/exposed_thing.dart

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -288,27 +288,38 @@ class ExposedThing implements scripting_api.ExposedThing, ExposableThing {
288288
}
289289

290290
@override
291-
Future<void> handleReadAllProperties(
292-
List<String> propertyNames,
293-
PropertyContentMap inputs, {
291+
Future<PropertyContentMap> handleReadAllProperties({
294292
int? formIndex,
295293
Map<String, Object>? uriVariables,
296294
Object? data,
297-
}) {
298-
// TODO: implement handleReadAllProperties
299-
throw UnimplementedError();
300-
}
295+
}) async =>
296+
handleReadMultipleProperties(
297+
thingDescription.properties?.keys.toList() ?? [],
298+
);
301299

302300
@override
303301
Future<PropertyContentMap> handleReadMultipleProperties(
304-
List<String> propertyNames,
305-
Content input, {
302+
List<String> propertyNames, {
306303
int? formIndex,
307304
Map<String, Object>? uriVariables,
308305
Object? data,
309-
}) {
310-
// TODO: implement handleReadMultipleProperties
311-
throw UnimplementedError();
306+
}) async {
307+
final contentMapEntries = await Future.wait(
308+
propertyNames.map(
309+
(propertyName) async {
310+
final content = await handleReadProperty(
311+
propertyName,
312+
formIndex: formIndex,
313+
uriVariables: uriVariables,
314+
data: data,
315+
);
316+
317+
return MapEntry(propertyName, content);
318+
},
319+
),
320+
);
321+
322+
return Map.fromEntries(contentMapEntries);
312323
}
313324

314325
@override

lib/src/core/protocol_interfaces/exposable_thing.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,14 @@ abstract interface class ExposableThing {
2626

2727
/// Handles a `readmultipleproperties` operation triggered by a TD consumer.
2828
Future<PropertyContentMap> handleReadMultipleProperties(
29-
List<String> propertyNames,
30-
Content input, {
29+
List<String> propertyNames, {
3130
int? formIndex,
3231
Map<String, Object>? uriVariables,
3332
Object? data,
3433
});
3534

3635
/// Handles a `readallproperties` operation triggered by a TD consumer.
37-
Future<void> handleReadAllProperties(
38-
List<String> propertyNames,
39-
PropertyContentMap inputs, {
36+
Future<PropertyContentMap> handleReadAllProperties({
4037
int? formIndex,
4138
Map<String, Object>? uriVariables,
4239
Object? data,

0 commit comments

Comments
 (0)