# When can i place vis.updateState();?

**URL:** <https://discuss.elastic.co/t/when-can-i-place-vis-updatestate/161185>\
**Category:** Kibana\
**Created:** [December 17, 2018, 3:41pm UTC](https://discuss.elastic.co/t/when-can-i-place-vis-updatestate/161185 "2018-12-17T15:41:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yasser\_Ouakil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yasser_ouakil/32/34466_2.png) [@Yasser\_Ouakil](https://discuss.elastic.co/u/Yasser_Ouakil)\
**Post date:** [December 17, 2018, 3:41pm UTC](https://discuss.elastic.co/t/when-can-i-place-vis-updatestate/161185/1 "2018-12-17T15:41:33Z")

</div>

Hi !  
i created a visualization and I want to update current state with values from vis.params.  
the problem is that the function is executed several times, and I want it to run only one time.  
So when can i place the fonction in my code ? i was tried in and out the $scope.$watch.

Thank you for your help !

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [December 20, 2018, 7:54pm UTC](https://discuss.elastic.co/t/when-can-i-place-vis-updatestate/161185/2 "2018-12-20T19:54:25Z")

</div>

Are you saying you don't want to watch the params for updates, you only want to set them once?

---

<div class="post-metadata">

**Author:** ![Yasser\_Ouakil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yasser_ouakil/32/34466_2.png) [@Yasser\_Ouakil](https://discuss.elastic.co/u/Yasser_Ouakil)\
**Post date:** [December 21, 2018, 3:04pm UTC](https://discuss.elastic.co/t/when-can-i-place-vis-updatestate/161185/3 "2018-12-21T15:04:45Z")

</div>

I can change my params in my dataviz but i can't save them,  
when i save the new values, and i reload the dataviz, i got it with the old values params.  
And when i use vis.updateState(); in my script and i save the new values, that's work, but that it saves every second, i don't know why ... i hope that you understand my issue.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 18, 2019, 3:04pm UTC](https://discuss.elastic.co/t/when-can-i-place-vis-updatestate/161185/4 "2019-01-18T15:04:51Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
