Skip to content

How to inject a raw property #33

Closed

Description

@jaxoncreed

I'd like to inject a raw property into my component (a string, number, or raw JSON variable). For example, I have this component:

interface SomeJsonInterface {
  a: string;
  b: {
    c: string;
    d: number;
  }
  e: number[];
}

interface SomeComponentArgs {
  someString: string;
  someNumber: number;
  someJson: SomeJsonInterface;
}

export class SomeComponent {
  constructor(args: SomeComponentArgs) {
    // ...
  }
}

How would I wire up this component in the configuration?

Activity

  1. rubensworks commented on Jan 13, 2021

    @rubensworks
    Member

    I assume you're using the generator in the solid server.
    If so, it will generate parameters for all fields (SomeComponent:_someString, SomeComponent:_someNumber, SomeComponent:_someJson_a, ...)
    You can find the exact param identifiers inside the autogenerated components folder.

    In that case, instantiating it via a config file happens in the standard way.
    So here this would look something like:

    {
      "@id": "urn:something",
      "@type": "SomeComponent",
      "SomeComponent:_someString": "abc",
      "SomeComponent:_someNumber": 123,
      "SomeComponent:_someJson_a": "def",
      ...
    }
  2. jaxoncreed commented on Jan 13, 2021

    @jaxoncreed
    Author

    Is there no way to provide so nice raw JSON? Do I have to do it via underscores?

  3. rubensworks commented on Jan 13, 2021

    @rubensworks
    Member

    No, there's no way to do this at the moment.

    But should be perfectly possible to implement this though.
    This would require some small changes in both Components.js, and the generator (setting @range JSON on someJson in jsdoc).

  4. locked and limited conversation to collaborators on Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions