-
Notifications
You must be signed in to change notification settings - Fork 451
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
Implement approach for delivering constants to the new frontend components #2708
Comments
PRs: There will be some merge conflicts once other recent PRs get merged so I'll refresh the PRs then. |
Tests passed. @asmecher mind code reviewing this approach for passing constants to the frontend? |
@NateWr, why not just use |
One of Vue.js's architecture choices is for components to be explicit about their dependencies and relationships to other components. That's why you have to name a
And then declare it again in the receiving component:
That leads to some unnecessary verbosity. We have to name the Their argument -- and I tend to agree -- is that this verbosity makes the code easier to read and easier to maintain. Someone working with one component doesn't need to go looking anywhere else to "know" the component. Their single-file components extend this principle so that everything (markup, logic, style) are all housed together. As projects evolve, it's easier to identify dead code. When a component goes, you don't need to discover what associated code you can get rid of. (I'll be bringing styles into the components soon.) I'd like to extend this to the PHP handlers for a component on the backend. The For these same reasons, I think a PHP handler which declares it's required constants will be easier to understand and maintain, even though it will be more verbose. I can think of a few cases where it will be helpful:
|
The flip side is that all the explicit statements of what-constant-is-needed-where will need to be maintained, and in my experience it'll lead to a cruft buildup as constants are added but never removed. We can see this aplenty in the locale files, import statements, etc.; if we were able to delegate all imports to an autoloader and do away with |
I think we're both trying to tackle the same problem, we just maybe see it's source in different places. The locale cruft and the difficulty of maintaining it is one the main reasons I prefer this approach, because it makes explicit the dependencies which are otherwise difficult to uncover. When we remove a constant from a |
pkp/pkp-lib#2708 Pass constants with JS handler configuration
pkp/pkp-lib#2708 Pass constants with JS handler configuration
#2708 Pass constants with JS handler configuration
Merged. I'm happy to re-evaluate down the line if we feel like it's not addressing our maintenance concerns well. |
There are a number of magic numbers in the new submission list panels that need to be replaced with proper constants.
Currently, we can pass constants defined in PHP to the JS frontend through the
defined_exposed()
function. This works at a global level (ie - constants must either be exposed or not exposed when defined). As more logic is handled in the new frontend handlers, we'll need access to more constants in JS land.I'd propose passing a
_constants
object with a handler's config. These can then be picked up byVueRegistry.init
and merged with apkp.constants
hash.The text was updated successfully, but these errors were encountered: