Skip to content

Commit

Permalink
refactor(coap_client): rename _deregisterObservation
Browse files Browse the repository at this point in the history
New name is complete, which corresponds to the
terminology in the ConsumedThing class.
  • Loading branch information
JKRhb committed Feb 19, 2022
1 parent 1abdd0a commit af36b2e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/src/binding_coap/coap_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ class _CoapRequest {
}

Future<_CoapSubscription> startObservation(
void Function(Content content) next,
void Function() deregisterObservation) async {
void Function(Content content) next, void Function() complete) async {
void handleResponse(coap.CoapResponse? response) {
if (response == null) {
return;
Expand All @@ -177,7 +176,7 @@ class _CoapRequest {

final requestContentType = coap.CoapMediaType.parse(_form.contentType);
await _makeRequest(null, requestContentType!);
return _CoapSubscription(_coapClient, deregisterObservation);
return _CoapSubscription(_coapClient, complete);
}

/// Aborts the request and closes the client.
Expand Down Expand Up @@ -387,10 +386,9 @@ class _CoapSubscription implements Subscription {

/// Callback used to pass by the servient that is used to signal it that an
/// observation has been cancelled.
final void Function() _deregisterObservation;
final void Function() _complete;

_CoapSubscription(this.coapClient, this._deregisterObservation)
: _active = true;
_CoapSubscription(this.coapClient, this._complete) : _active = true;

@override
Future<void> stop([InteractionOptions? options]) async {
Expand All @@ -402,6 +400,6 @@ class _CoapSubscription implements Subscription {
// approach instead for the time being.
coapClient.close();
_active = false;
_deregisterObservation();
_complete();
}
}

0 comments on commit af36b2e

Please sign in to comment.