Code/JS API to refresh a visualization

Hello. I am writing a custom Kibana plugin.

When the parameters in the editor change and somebody pushes the play button, how do I refresh my visualization, I am not getting notified when parameters or the search filter changes. I tried looking at the plugins listed as examples in the known plugins page - https://www.elastic.co/guide/en/kibana/current/known-plugins.html .

Most of them, do not change visualization unless you refresh the page. Is there an example which I could look into to better understand how the change in parameter is handled in a proper 5.5.0+ compatible plugin.

all the core_plugins visualizations (the ones provided out of the box) refresh on clicking the play button, so maybe its best to look there ...

what branch are you developing on ?

True. All 'core' plugins do refresh on clicking the play button. But you probably have an observer/event which captures that and calls your code so it could react to it. Can someone point me out to a specific code snippet at github where this event happens. I tried looking but it is not clear to me how it is being done ? There does not seem to be much documentation.

I am on the branch tagged v5.5.0 at github.com/elastic/kibana repo.

and i guess you are using template vis type ?

$scope.$watch('vis.params', () => {
   // params got updated
});

i think something like this should work. let me know how it goes.

and tag cloud is probably the simplest vis to check:

Thanks. I got it working through the multiwatch since we need to monitor both 'esResponse' and 'vis.params'