Skip to content

fix: cancel the filter subscription after HitSearcher is disposed#174

Open
martin-ideeri wants to merge 1 commit into
algolia:mainfrom
martin-ideeri:feat/cancel-filter-subscription-on-dispose
Open

fix: cancel the filter subscription after HitSearcher is disposed#174
martin-ideeri wants to merge 1 commit into
algolia:mainfrom
martin-ideeri:feat/cancel-filter-subscription-on-dispose

Conversation

@martin-ideeri

Copy link
Copy Markdown
Q A
Bug fix? yes
New feature? no
BC breaks? no
Related Issue N/A
Need Doc update no

Describe your change

  • Bring the connectFilterState inside of the HitsSearcher class instated of being an extension
  • Take advantage of the already existing CompositeSubscription, add the filter sub to it so that it is cancelled on dispose by the _subscriptions.dispose(); call inside of doDispose.

What problem is this fixing?

Currently, when we plug a FilterState into a HitsSearcher via the connectFilterState extension method, we listen to a stream of changes and update the internal search state whenever said filters change. This is fine, but when we dispose of the HitsSearcher there is no easy way to "unplug" the filter state from the searcher. We then have theses log entries :

Algolia/HitsSearcher: modifying disposed instance

This is not a huge issue, there is a check to prevent doing anything bad :

    if (_request.isClosed) {
      _log.warning('modifying disposed instance');
      return;
    }

But it's still IMO cleaner to close the sub after disposing of the searcher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant