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.

Is it possible to watch state changes from connectGeoSearch mixin?

See original GitHub issue

Feature ⚡️

What is your use case for such a feature?

Hi I would like to ask if I can watch changes from state.items from connectGeoSearch mixin?

Currently, I have no information about state.items see also official docs tutorial for context.

Currently, i need to create a workaround with setTimeout to get sure the state.items has been updated. Is there any better solution (subscription, watcher) to let us know when the state has been updated?

  • Map.vue (child)
  methods: {
    async recenterMap() {
      console.debug("this.state.items:",this.state.items);

      // i need this in an real app to get sure the store has been updated
      await new Promise(resolve => setTimeout(resolve, 150));

      let geoloc = this.state.items.map(ds => [ds._geoloc.lat, ds._geoloc.lng]);
      this.map.fitBounds(geoloc);
    }
  }
  • Index.vue (parent)
onSearch() {
      this.$refs.mjmap.recenterMap();
}

What is your proposal

watcher, subscription …

Demo

I tried to rebuild this in a codesandbox with two different fakedata which should replace the current state with math.random (i know poor example): https://codesandbox.io/s/algolia-vue-instantsearch-v3-geosearch-recenter-m9clf

What is the version you are using?

latest.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
regenrekcommented, Jul 25, 2019

Thanks for your answer. Yeah I ended up using watch. Works for me

    "state.items"() {
      if (this.state.items.length > 0) {
        this.recenterMap();
      }
      console.debug("state.items updated", this.state.items);
    }
0reactions
Haroenvcommented, Jul 25, 2019

Is there a reason watch: { 'state.items' ... does not work for you?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Geo search with Vue InstantSearch - Algolia
We will see how we can leverage the geo search capabilities of Algolia with the connectGeoSearch connector. This demo is built with Google ......
Read more >
Watch for Vuex State changes! - DEV Community ‍ ‍
If I use the normal watcher on user it gets invoked, but the values don't seem to be there. I can log them...
Read more >
instantsearch.js - UNPKG
This feature helps you make more efficient UIs with multiple result lists, autocomplete, nested interfaces and query suggestions. You can read more about...
Read more >
How to build a breakfast restaurant locator with nuxtjs and ...
But if you into modern web development with possible wordpress ... do we want to have or where should we :center the map...
Read more >
Map markers not updating with v-for (#21) · Issues - GitLab
As you can see, the marker and its contents get shown under the actual map. ... the same problem using a normal array...
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