I have an event listener that records the value of a toggle slicer in my application. The toggle can have value set to OFF or ON.
I have a variable called filteredValue which contains the value of the current toggle state
let filteredValue = state.filters[0].values;
I need to apply an action when the value of that variable changes.
eg
report.on('rendered', async () => {
//get all pages
const pages = await report.getPages()
//get active page
let activePage = pages.filter(function(page) {
return page.isActive
})[0];
//get visuals on active page
let visuals = await activePage.getVisuals();
//find target visual
const TargetVisual = visuals.filter(function(visual) {
return visual.name === "259fea6751434e7910b4"
})[0];
//get current state of visual
const state = await TargetVisual.getSlicerState();
//get current state value (on or off )
let filteredValue = state.filters[0].values
// DO SOMETHING HERE ONLY WHEN filteredValue CHANGES
}