Skip to content

Commit

Permalink
fixup! feat!: improve TD serialization behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Jan 3, 2024
1 parent 128bb26 commit 0987df7
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions lib/src/core/consumed_thing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,13 @@ class ConsumedThing implements scripting_api.ConsumedThing {
final OperationType operationType;
final Map<String, Subscription> subscriptions;

if (subscriptionType == SubscriptionType.property) {
operationType = OperationType.observeproperty;
subscriptions = _observedProperties;
} else {
operationType = OperationType.subscribeevent;
subscriptions = _subscribedEvents;
switch (subscriptionType) {
case SubscriptionType.property:
operationType = OperationType.observeproperty;
subscriptions = _observedProperties;
case SubscriptionType.event:
operationType = OperationType.subscribeevent;
subscriptions = _subscribedEvents;
}

final (client, form) = _getClientFor(
Expand All @@ -306,10 +307,12 @@ class ConsumedThing implements scripting_api.ConsumedThing {
},
complete: () => removeSubscription(affordanceName, subscriptionType),
);
if (subscriptionType == SubscriptionType.property) {
_observedProperties[affordanceName] = subscription;
} else {
_subscribedEvents[affordanceName] = subscription;

switch (subscriptionType) {
case SubscriptionType.property:
_observedProperties[affordanceName] = subscription;
case SubscriptionType.event:
_subscribedEvents[affordanceName] = subscription;
}

subscriptions[affordanceName] = subscription;
Expand Down

0 comments on commit 0987df7

Please sign in to comment.