Reactive Grafana variables in plugin

Currently in my custom plugin I am using getTemplateSrv in order to grab dashboard variables from my grafana dashboard. However when I have a query variable when that variable updates that change isnt reflected in the plugin and therefore functionality relying on that variable isnt updating.

Currently I use this to grab variables,
This works for the inital state of the varible, however as the query in the variable runs it doesnt update on the plugin side.

I have implementing polling in order to make sure I also have the current variable however this solution doesnt scale and is a bad solution. are there any other methods to get grafana variables that always are updated with the current value?

@nulluser You can use EventBus to catch the variables updates and other events:

1 Like

Worked like a charm, tysm.

1 Like

Can you add more details on how data source plugin can retrieve data from the Grafana data source?