-
Notifications
You must be signed in to change notification settings - Fork 5
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
Expose application configuration #139
Comments
cc @barsimatyi |
So this is how it would work:
task packageApp(type: PackageApplication) {
parameters param1: "alma", param2: "bela"
}
define("application-config", [], function() {
return {
version: "1.0", // auto-generated from Gradle version
param1: "alma",
param2: "bela",
};
});
require(["<main-module>"], function(mainModule) { mainModule.main(); }); The module's JS: define([..., "application-config"], function(..., applicationConfig) {
// Weird Spaghetti wrapping that exposes applicationConfig as Spaghetti.getApplicationConfig()
// ...
..., function(Spaghetti) {
console.log("Config:", Spaghetti.getApplicationConfig());
});
// ...
}); Console output: $ node application.js
Config: {
version: "1.0",
param1: "alma",
param2: "bela",
} |
Valid point from @gnagy: it's better to not have shared state like this, and only expose this configuration to
define("application-config", [], function() {
return {
version: "1.0", // auto-generated from Gradle version
param1: "alma",
param2: "bela",
};
});
require(["<main-module>", "application-config"], function(mainModule, config) {
var appConfig = someWrappingOfConfig(config);
mainModule.main(config);
}); |
We'd need a extern class SpaghettiParameters {
function getParameter(name:String):Dynamic;
} So an application module could declare its main method as such:
This would allow obfuscation-safe access to the parameters, too. |
Add it somehow to the generated
application.js
. Maybe this could be wrapped into a separate "module" (metadata
?application
?) that modules couldrequire()
. This way it could be introduced in a non-breaking way.The text was updated successfully, but these errors were encountered: