question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Only call Algolia under certain conditions

See original GitHub issue

I’m using the query-parameters in attributes in order to pass some filters to Algolia. I am using a reactive attributes to be able to change the query parameters.

<ais-index :query-parameters="param" app-id="latency" api-key="qq" index-name="movies">

[…]

...
  data() {
    return {
      param: {}
    }
  },
  
  mounted() {
    // typically perform ajax call
    this.param = { filters: 'genre:drama' };
    
  }

In my actual app I’m call the my backend to be able to update the params.

Algolia will before a first call without the filters then when the params are updated, another call is performed. Since the ajax call is slow it creates a flickering effect.

I’d like to avoid the first call.

Here is a working example (it’s too fast so you’ll have to look at the XHR calls). https://codepen.io/julienbourdeau/pen/YQYZQw

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
rayrutjescommented, Jul 3, 2017

Ok, so in that case, you must indeed call stop() on the store and call start() once you get your data.

Internally the store keeps a counter of the number of times it was “stopped”, in a way that any part of your code can control wether to freeze or not the syncing with Algolia.

Here is a POC (not tested and jsfiddle doesn’t like es6 import but it gives you the main idea): https://jsfiddle.net/hmg1f15k/2/

Let me know if that doesn’t work/help @julienbourdeau

Read more comments on GitHub >

github_iconTop Results From Across the Web

Conditional requests with InstantSearch.js - Algolia
This proxy lets you add some logic before calling the search method. In this case, you only call it when performing a query....
Read more >
Implementing Rules - Algolia
Go to the Rules tab for a selected index and click on Add Rule. ... A Rule with filter values in the condition...
Read more >
Rules overview - Algolia
Rules consist of three parts: conditions, consequences, and a validity period. Of these three parts, only the consequence is required.
Read more >
Filtering | Algolia
Filtering allows your users to drill-down and create a smaller, more manageable set of data based on meaningful categories.
Read more >
Search REST API Reference - Algolia
More formally: query N is executed only if all of queries 0 through N-1 had ... Perform multiple write operations in a single...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found