Skip to content

Commit

Permalink
Cancel the subscriptions of both SpineSubscription and Proto `Subsc…
Browse files Browse the repository at this point in the history
…ription` types by using their IDs.

Improve the formatting of type-level docs.
  • Loading branch information
armiol committed Jan 30, 2023
1 parent 951bcd2 commit f75bd3a
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions client-js/main/client/firebase-subscription-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import {Status} from '../proto/spine/core/response_pb';
const DEFAULT_KEEP_UP_INTERVAL = new Duration({minutes: 2});

/**
* A service that manages the active subscriptions periodically sending requests to keep them
* running.
* A service that manages the active subscriptions periodically sending requests
* to keep them running.
*/
export class FirebaseSubscriptionService {

Expand Down Expand Up @@ -177,10 +177,22 @@ export class FirebaseSubscriptionService {
* Removes the provided subscription from subscriptions list, which stops any attempts
* to update it. In case no more subscriptions are left, stops this service.
*
* In case the passed subscription is not known to this service, does nothing.
*
* @param subscription a subscription to cancel;
* this method accepts values of both `SpineSubscription`
* and Proto `Subscription` types,
* and operates based on the subscription ID
* @private
*/
_removeSubscription(subscription) {
const index = this._subscriptions.indexOf(subscription);
let id;
if (typeof subscription.id === 'function') {
id = subscription.id();
} else {
id = subscription.getId().getValue();
}
const index = this._subscriptions.findIndex(item => item.id() === id);
this._subscriptions.splice(index, 1);

if (this._subscriptions.length === 0) {
Expand Down

0 comments on commit f75bd3a

Please sign in to comment.