Skip to content

LiveQuerySubscription -> Subscription::unsubscribe call to undefined resolve function #639

Closed
@ideastouch

Description

@ideastouch

On file LiveQuerySubscription.js, line 109, which is class Subscription, method unsubscribe(), at the end is called this.resolve();
My code crash and says "unsubscribe resolve is not a function", which is true. I think that is a bug.
BTW: I couldn't find in test files any test checking "unsubscribe" function.

class Subscription extends EventEmitter {
  /*
   * @param {string} id - subscription id
   * @param {string} query - query to subscribe to
   * @param {string} sessionToken - optional session token
   */
  constructor(id, query, sessionToken) {
    super();
    this.id = id;
    this.query = query;
    this.sessionToken = sessionToken;
  }

  /**
   * closes the subscription
   */
  unsubscribe() {
    return CoreManager.getLiveQueryController().getDefaultLiveQueryClient().then((liveQueryClient) => {
      liveQueryClient.unsubscribe(this);
      this.emit('close');
      this.resolve();
    });
  }
}

In the meanwhile I added to my subscription object created with query.subscribe() the static function promise.resolve from npmjs package 'promise'. Basicaly my code is:

	if (is.nullOrUndefined(this.mytSubscription.resolve)) {
		this.mySubscription.resolve = Promise.resolve; }
	this.mySubscription.unsubscribe();
	this.mySubscription = undefined;

Best,
Gus

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions