qSocks snippets extension for VSCode

qlik sense   snippet   vscode  

At the moment VSCode is my preferred code editor (although I'm side using Atom sometimes as well). And when I'm writing something which uses qSocks I've always have GitHub and Qlik Sense help site open so I can check the available methods and what parameters need to be provided for these methods. Plus I'm a "bit" lazy and always copy/paste code from another projects I have and adapt it to the current needs.

For these reasons I've made VSCode snippets extension. The extension is used from within VSCode and include all qSocks methods as snippets. Just type qsocck and pick the method that you need.

For example if qsocks.global.qTProduct method is picked the following code will be generated:

global.qTProduct().then(function(product) {

});

If your local variable is different from global you just need to replace it in the generated code. Also the returned variable product can be replaced if you are not happy with the convention. But the main code will be generated automatically.

The same is applied and for the request parameters. For example the qsocks.global.createSessionAppFromApp method expect source app id as parameter. The snipped will generate the following code:

global.createSessionAppFromApp('qSrcAppId').then(function(sessionApp) {

});"

In the above example qSrcAppId need to be replaced with the app id you need (also global and sessionApp if you want)

Another advantage of using snippets is that you can prepare your logic very quickly instead writing (or copy/paste from somewhere) all the code. Just chain your methods, quickly picking them from the list, change the necessary input/output variables and focus on building your internal logic.

The extension include snippets for all qSocks methods:

  • main (config and connection)
  • doc
  • global
  • field
  • generic Bookmark
  • generic Dimension
  • generic Measure
  • generic Object
  • generic Variable

To install the extension:

  • open VSCode
  • press Ctrl+P
  • paste ext install qsockssnippet
  • follow the instructions (VSCode need to be restarted in order to install the extension)
  • thats it - just start typing qsocks and pick the method.

Hope you like it!
Stefan