4 Replies Latest reply: Apr 20, 2016 8:13 PM by Alexander Karlsson RSS

    getList method and destroySessionObject

    Michael Rutter

      Hi,

       

      Using Qlik Sense 2.2 as part of a single page react/redux application. I need to use the getList method to get the current state of selections within a Qlik Sense app. I have a react view that calls this:


      app.getList("SelectionObject", function(reply){

           ...
      }

       

      So this seems to subscribe to all selection events asynchronously and runs my callback function whenever the state changes in the qlik application. Works well and serves my purposes.

       

      I then need to destroy my view when the user moves to another part of my application and along with it any of these async callbacks, which seems to be the job of destroySessionObject. It is documented as being able to:


      destroy a Qlik Sense session object created with createGenericObject or any of createCube,createList or getList methods.


      So just before I destroy my view I call this:


      app.destroySessionObject('SelectionObject')

      or

      app.destroySessionObject(variable) // variable that is assigned to the app.getList I invoked earlier.


      Unfortunately, there is something still subscribed to qlik sense selection events for this app and it is invoking my callback function resulting in errors and possible unintentional side effects. If I pass it the 'SelectionObject' string nothing really seems to happen and it returns and object with some undocumented methods:


      If I pass it the variable I get the following error:

      1. Object {jsonrpc: "2.0", id: 76, error: Object}
        1. error:Object
          1. code:-32602
          2. message:"Invalid method parameter(s)"
          3. parameter:"JSON type error"
          4. __proto__:Object
        2. id:76
        3. jsonrpc:"2.0"

       

       

      Anyone have any ideas?

        • Re: getList method and destroySessionObject
          Michael Rutter

          Solution:

           

          It isn't documented very well, but reply within the callback of getList includes a string here:
               reply.qInfo.qId

           

          For getList this is the identifier required for destroying the session. So in react I added the string to my view's state and used it to kill the async function using destroySessionObject.

           

          Can I suggest to those maintaining documentation that the documentation was a little less... terse...

            • Re: getList method and destroySessionObject
              Alexander Karlsson

              So a bit off-topic,

              How did you end up implemented the Qlik models into Redux? We always felt that "stores" felt a bit over-the-top since Qlik already handled the state of your data already.

                • Re: getList method and destroySessionObject
                  Michael Rutter

                  Well at the moment I'm effectively only using Qlik to bring in visualisations (more or less complete worksheets) using the getObject method. I needed to use those other methods, such as getList and clearAll, in order to reimplement the CurrentSelection bar as a react component. The existing one provided by Qlik breaks if you have more than one app open at the same time within your active view.

                   

                  So far I've learned that I cannot haphazardly open and close websocket connections every time the user changes views especially if the user expects to be able to navigate back to a previous view quickly. So I've created a react component to act as container for sets of views that maintain that connection. One part of my application with four distinct screens requires three simultaneous app connections to avoid everything breaking. Consequently, the CurrentSelections bar breaks when the user navigates to this part of my application. I just cobbled together an almost identical one in terms of look and functionality minus the search feature that I didn't look too much into.

                   

                  I will probably look at pulling in data directly from Qlik at some point to build some D3/leafet stuff as React components, but you are right that when it comes to Qlik stuff using a redux store might be overkill as Qlik is quite possessive about managing its state. I will likely be using my redux store for other things that don't directly involve Qlik. As of right now its a React + React Router application.

                    • Re: getList method and destroySessionObject
                      Alexander Karlsson

                      Interesting, we are also building a React + React Router app ontop of the Engine API and has been going back and forth if we should let Redux handle the data for us in addition to the UI state.

                       

                      We aren't completely sold yet, instead we created like you a wrapper component that constructed the hypercubes and then passed the data down into our charting components. Worked ok so far but then again it's a small app