GetProgress() (Qlik Sense)

Part of one of my projects was to reload app on the fly. The whole process is working fine (more on this in a different post) but wanted to show the reload progress to the user.

For this purpose we can use GetProgress() method from Qlik Sense Engine API

The code below uses qsocks and shows how to get the reload progress from NodeJS app:

    qsocks.Connect(qsConfig).then(function(global) {
        global.productVersion()
            .then(function(version) {
                return console.log('*** Connected to QS Engine Service')
            })
            .then(function() {
                return global.openDoc('DOCUMENT ID')
            })
            .then(function(doc) {

                var reloaded = null; // when the app is finished to reload
                doc.doReload().then(function() {
                    reloaded = true;
                    console.log('Reloaded');
                });

                var persistentProgress = '';

                var progress = setInterval(function() {

                    if (reloaded != true) {
                        global.getProgress(0).then(function(msg) {
                            if (msg.qPersistentProgress) {
                                persistentProgress = msg.qPersistentProgress;
                                console.log(msg.qPersistentProgress + ' <-- ' + msg.qTransientProgress)
                            } else {
                                if (msg.qTransientProgress) {
                                    console.log(persistentProgress + ' <-- ' + msg.qTransientProgress)
                                }
                            }
                        })
                    } else {
                        clearInterval(progress)
                    }
                }, 500); // get the reload progress every 500ms
            })
    })

`

Hope you like it!
Stefan