LinkedSoftwareDependencies / Components.js

🧩 A semantic dependency injection framework
https://componentsjs.readthedocs.io/
Other
41 stars 6 forks source link

Allow overriding variables that have been assigned a value in the configuration file #23

Open RubenVerborgh opened 3 years ago

RubenVerborgh commented 3 years ago

Variables have been added to Components.js in v3.6.0. We can set them programmatically: https://github.com/solid/community-server/blob/e1533a0869071bbeabf0edfdfd05ccf57883cdaa/src/init/CliRunner.ts#L42-L46

However, could I also give them a value inside the Components.js config? https://github.com/solid/community-server/commit/1dd140ab61845ae8df67c16883136736146549dd#diff-fec64cbd09e800f0351eb81eaaef521a1b9fecef9f81a3584d513e4f1266b6c0R4-R15 That might be handy to propagate string/number values around.

rubensworks commented 3 years ago

Actually, something like this may already work (untested):

{
  "@id": "ex:myComponentInstance",
  "ex:param": { "@id": "ex:myVariable" }
}
{
  "@id": "ex:myVariable",
  "value": "123"
}
RubenVerborgh commented 3 years ago

They can act as a default that can be overwritten by configuration. (On that note… can we overwrite any component? 😛)

rubensworks commented 3 years ago

On that note… can we overwrite any component?

You can only overwrite default values in parameters. If you actually instantiate a param's value, you can only append values, not overwrite them.

RubenVerborgh commented 3 years ago

value conformed working (for variables); I love it.

RubenVerborgh commented 3 years ago

Mmm, was too soon. Seems like variables with a configured value cannot be overridden.

RubenVerborgh commented 3 years ago

Actually, something like this may already work (untested):

{
  "@id": "ex:myComponentInstance",
  "ex:param": { "@id": "ex:myVariable" }
}
{
  "@id": "ex:myVariable",
  "value": "123"
}

Actually, only the first one works; the second one does not.