Skip to content

Instantly share code, notes, and snippets.

@theredpea
Last active February 6, 2018 23:19
Show Gist options
  • Select an option

  • Save theredpea/9bdc361ab22948b5906e4a8e89dfed93 to your computer and use it in GitHub Desktop.

Select an option

Save theredpea/9bdc361ab22948b5906e4a8e89dfed93 to your computer and use it in GitHub Desktop.
g.currApp = function(e) {
var n;
return (n = e && e.backendApi && e.backendApi.model.session && e.backendApi.model.session.currentApp ?
//if there's e.backendApi.model.*session*.currentApp, then assign to n
e.backendApi.model.session.currentApp
//else if there's not assign ...
: e && e.backendApi && e.backendApi.model.app ?
//if there is e.backendApi.model.*app*
e.backendApi.model.app :
//else assign to t.current
t.current) ?
//if `n` has some value, then:
(x || (x = new g(n)), x.model === n ?
//if x.model is n, then: return x
x
//else if x.model is not n, then: return new instance
: new g(n))
: null
}
{
g: 'represents the qlik object; can use with `new`; g is the function at start of `apis/qapp` , has properties like `global`, `bookmark`, `visualization`, `theme`, has functions assigned to its `prototype`. However currApp and openApp are not defined on `prototype`',
e: 'represents argument passed in; I never use it that way; only call currApp(...)' +
'Since e never has a value then it falls through all safety checks and expects t.current to have a value',
t: 'represents core.models/app : define("apis/qapp", ["core.utils/deferred", "core.models/app", ...], function(e, t, ...'+
'Notice that if `t.curent` doesnt have a value, it will return null. We can move past currApp to understand t better; core.models/app'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment