-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean and reasonable project structure #694
Conversation
- pages folder for app's sections - services folder for app-wide services (ajax, authentication) added generic Component class for knockout components inheritance decompose dashboard report from datasources page on separate atomic components
introduced module-level resources folder added treemap report
|
||
<div id="report" class="flexed" data-bind="if: currentReport() && ! hasError()"> | ||
<div class="row pad-10 report"> | ||
<!-- ko if: $component.currentReport().name == 'Dashboard'--> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried the component binding without a container element?
See: http://knockoutjs.com/documentation/component-binding.html
Like so:
<!-- ko component: {
name: $component.currentReport().name,
params: { context: $component }
} -->
<!-- /ko -->
The component will reload based on the value of currentReport().name (or you can introduce a new property on the report called 'componentName' in the case that you want to keep the name of the report separate from the name of the component for this report.
This would replace the need for the set of <!-- ko if: .... -->
statements you have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I never knew there's such binding, thanks for the hint!
Hello everyone, So, first question/comment: using packages and what it means for dynamic loading of pages: I like packages, and I enjoy how they can take a group of related files together and let you load a unit of functionality together without having to mess with a bunch of paths configs; you just define a package name, point it to an entry module (by default: main.js) and you're done. The problem I see with how packages is being used here (for the package: 'pages'), is that as we add more and more pages under the 'pages' package, the application will pre-load all the dependencies regardless if the user needs them immedately. What we'll wind up with is that doing a requre(['pages']) will load the entire app, when we want to lazy load the application. Currently, we lazy-load modules based on the route accessed: within the route handler, we do Should we think about 'package-per-page' mindset, or not use packages all together so that we can lazy load only the pages that we immediately need? |
Hi @chrisknoll |
Hi, @johnSamilin,
Very cool, it makes sense that routes need to be loaded up front, otherwise the routing library won't know what to do with a given path. Do you think it's possible, in the future, that we leverage a routing library that can register sub-routes at runtime based on a root route? The reason I ask: data-sources routs get loaded, then when you access /data-sources route, it triggers the require() to load in all the reports. Could we get to yet another level of lazy loading, by only loading the specific sub report when requested? So if someone goes to /datasources/condition/{concept_id} (which, we don't actually have routes for this, I know) the routing library would be like: I'm not suggesting we make any changes to support this functionality (since we're just talking about project structure here) but since we are handling routes a little differently, I wanted to put the question on the table about what you thought about dynamic building of route tables on the fly...with the extra twist that as a route is being processed, the child routes could be added to the route table so that the required assets get loaded as the routes get initially discovered. |
Re: the pages package's main.js In the main.js for the pages package, we're loading up ./data-sources/index module, which in turn loads up the routes and returns them. Is there any reason we could skip that intermediate index.js and just load the routes directly in main.js? Then all that the purpose of main.js is to establish the routes that are necessary for the package, and then as the routes are invoked, the sub-resources will be pulled in. |
Hello, everyone, If you do proceed with the PR as-is: please squash those commits down into a 'folder restructure - Part 1' commit. Thank you! |
Refactored data sources component to make it a separate page
according to issue #633