I'm trying to convert my app to multipage app, but facing some issues with how scopes work.
I have an app, where everything is handled inside of a one tabbed container, that acts just like pages. It's made this way, because I often need to pass or access data between pages.
And to explain my problem, I will give a little example:
In my main app I have a js script, that looks at the current tab and depending on it loads necessary queries.
For example, if I open Customers tab, my js script runs
if (customers_data.data == null) {
await customers_data.trigger();
}
or, if I go to the Projects tab, it runs next code:
if (technologies.data == null) {
await Promise.all([
technologies.data == null && technologies.trigger(),
projects_data.data == null && projects_data.trigger()
]);
}
and so on.
And now the issue for me with global scoped instances, is that I can access their data from different pages, but global scoped script itself can't take data from page scoped instances:
loadTabQueries failed (0.035s):Unable to access 'TTR_data' since it is scoped to 'timeTracking'. 'loadTabQueries' is scoped to the app.
Following the example above, now, if I convert my app to a multipage app, make that js script global scoped - it won't be able to trigger any of those queries, because they remain page scoped.
Maybe it is how it was intended to work, but for me that's a bit counterintuitive, that something from the global scope, being global, can't access everything.
For now I came to conclusion, that it is probably needed to move queries like projects_data and customers_data to the global scope right?
I'm asking, because it is not that ideal, because those queries actually aren't used anywhere except their pages, and maybe I'm missing on some better solution.