-
Notifications
You must be signed in to change notification settings - Fork 6
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
GPII-3698 Work in progress #28
base: main
Are you sure you want to change the base?
Conversation
- Changing the event that we render on to be onAllResourcesLoaded rather than onTemplatesLoaded so all implementations can render on the same event.
…from options area.
"onTemplatesLoaded": null, | ||
"onAllResourcesLoaded": { | ||
events: { | ||
// onMessagesLoaded: "onMessagesLoaded", |
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.
You need to explain why you commented onMessagesLoaded
out. If there' s a new mechanism that ensures that rendering can take place after messages are loaded, fine, then it should be removed. If it's here for some other reason, you need a TODO or comment.
"onTemplatesLoaded": null, | ||
"onAllResourcesLoaded": { | ||
events: { | ||
// onMessagesLoaded: "onMessagesLoaded", |
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.
This is a bit baffling, you still have the rollup event, and you still launch the template retrieval, but you've commented out the templatesLoaded event twice?
@@ -130,7 +130,7 @@ | |||
type: "gpii.handlebars.renderer.serverAware", | |||
options: { | |||
listeners: { | |||
"onTemplatesLoaded.renderMarkup": { | |||
"onAllResourcesLoaded.renderMarkup": { |
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 think the rollup is a good improvement and will help once we figure out what's going on with template loading.
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.
Just to clarify, I mean that if we choose to support an event-based approach, a rollup is an improvement.
type: "gpii.handlebars.renderer.serverAware" | ||
// TODO sgithens This needs to be updated depending on the app from serverAware to | ||
// serverMessageAware dynamically. | ||
type: "gpii.handlebars.renderer.serverMessageAware" |
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.
You could argue that we could put comments next to any type when there are variants, but that puts the burden on implementers to know which code to read and to read it. If this switch is required often enough, maybe a mix-in grade that does this would help? i.e. a templateManager.serverMessageAware grade that is also mentioned in the docs and used in tests?
var messages = fluid.get(rootContext || dataOrRootContext, "data.root.messages"); | ||
|
||
var messages; | ||
if (serverAware) { |
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.
We should have another meeting with @amb26 during our overlap, this is getting a bit out of hand and it's largely my fault. I started this "server aware" pattern long ago, and it seems wrong headed for the long term. I think we'd be better off migrating to something like named global variables for message bundles, templates, et cetera, or at least using something standard like a resource loader. We should also at least figure out how/if we can avoid mixing events and model changes as we do currently.
// If we have a third argument, then the second argument is our "data". Otherwise, we use the root context (equivalent to passing "." as the variable). | ||
var data = rootContext ? dataOrRootContext : fluid.get(dataOrRootContext, "data.root"); | ||
// TODO var data = rootContext ? dataOrRootContext : fluid.get(dataOrRootContext, "data.root"); |
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.
OK, this is another case where you've neutered a feature without any comment on why, and left the old functionality commented out. What's your thinking here?
@@ -35,7 +41,7 @@ fluid.defaults("gpii.handlebars.helper.messageHelper", { | |||
invokers: { | |||
"getHelper": { | |||
"funcName": "gpii.handlebars.helper.messageHelper.getHelper", | |||
"args": ["{that}"] | |||
"args": ["{that}", "{gpii.handlebars.renderer.serverAware}"] |
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.
If we do end up needing both "server aware" and "non server aware" in the short term, I'm wondering if we can automatically handle this using context awareness so that people only need to use the single grade.
@@ -121,7 +121,8 @@ var Handlebars = Handlebars || {}; | |||
defaultLocale: "en_us", | |||
defaultLayout: "main", | |||
events: { | |||
onTemplatesLoaded: null | |||
onTemplatesLoaded: null, |
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.
We should discuss whether there should be an onMessagesLoaded
event here as well, however we agree to handle things, the approach should be reflected in the common grade as well.
@@ -97,7 +98,13 @@ | |||
} | |||
}, | |||
events: { | |||
"onTemplatesLoaded": null | |||
"onTemplatesLoaded": null, | |||
"onAllResourcesLoaded": { |
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.
If we decide to use async activities to populate templates and messages, one option would be to have a promise chained event that handles the loading and which fires onAllResourcesLoaded
as its last step.
@sgithens and @amb26, I think I'm starting to understand the intent behind this pull, but I think we should meet to discuss whys and hows a bit. While we wait, it would be good to at least have an approach that actually passes the associated tests. In its current state, the commented out passing of |
See GPII-3698 for details. |
CI job failed: https://ci.gpii.net/job/gpii-handlebars-tests/1/ |
@sgithens, I have been working to fix the CI config for this project. If you merge with master and commit, you should have everything you need to run tests against your work. |
|
@the-t-in-rtf This is my WIP of what has been needed to fixup the messageHelper for use in both the server and client side in a full gpii-handlebars based project (gpii-devpmt)