1 Reply Latest reply on Oct 11, 2019 9:35 AM by Geordan Keller

    FILTER_CHANGE event getting called multiple number of times

    Akshar Jamgaonkar

      Hi All,

       

      I am listening to FILTER_CHANGE event on the viz but the function onFilterChange is getting called multiple number of times,

       

      onFirstInteractive: function(){
                tableauViz.addEventListener(tableau.TableauEventName.FILTER_CHANGE, onFilterChange);
                tableauViz.addEventListener(tableau.TableauEventName.MARKS_SELECTION, onMarksSelection);
              }
      }
      
      

       

      I am trying to save the filters users has applied for processing in the database, but the function is getting called multiple number of times.

       

      Any help in this would be really great.

        • 1. Re: FILTER_CHANGE event getting called multiple number of times
          Geordan Keller

          I also have this question.

           

          With the following code, my onFilterChanged() function is called twice when I change a filter in the viz.

          const unregisterOnFilterChangedEventListener =worksheet.addEventListener(tableau.TableauEventType.FilterChanged, onFilterChanged);

           

          I also tried debouncing using Underscore.js's debounce function but onFilterChanged() is still called twice:

          const unregisterOnFilterChangedEventListener =worksheet.addEventListener(tableau.TableauEventType.FilterChanged, debounce(function(evt) { onFilterChanged(evt); }, 500));

           

          I am also curious about where and when I might use the unregister function since there does not appear to be a tableau.extensions.deinitializeAsync() or destructor mentioned in the API reference. I am using the debugger as described at https://github.com/tableau/extensions-api/blob/master/docs/trex_debugging.md, and when I reload the inspector window it reloads the extension webpage, but leaves all event listeners that were previously attached in tableau.extensions.initializeAsync() attached, so it seems like reloading the inspector is not a good way to reload the extension webpage but that I must click the extension dropdown arrow in the dashboard layout and choose Reload. However doing this breaks the debugger connection and then I have to close the Chrome inspector window and reopen it every time.

           

          Edit: Changing from 500 to 1500 ms seems to have fixed the issue.

          Still, this bug should be fixed if it is a bug.