Skip to content
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

Allow component JavaScript constructor to take a config object #2698

Closed
3 tasks done
Tracked by #1708
vanitabarrett opened this issue Jul 15, 2022 · 4 comments · Fixed by #2826
Closed
3 tasks done
Tracked by #1708

Allow component JavaScript constructor to take a config object #2698

vanitabarrett opened this issue Jul 15, 2022 · 4 comments · Fixed by #2826
Assignees
Milestone

Comments

@vanitabarrett
Copy link
Contributor

vanitabarrett commented Jul 15, 2022

What

Allow components to take a config object through their constructor, before being initialised. The config object should default to an empty object, and therefore a component must be able to continue working even if the config object is empty (e.g: by setting some defaults to fall back on).

Why

To allow for options to be passed to our component JavaScript in future, e.g: translations

Who needs to work on this

Developers

Who needs to review this

Developers

Done when

  • It's possible to pass a config object to a component via init() and initAll()
  • If that config object is empty, the component JavaScript should still work
  • Tests to handle different scenarios and that the JS behaves as expected, e.g: config object not passed, config object is empty, component sets defaults
@querkmachine
Copy link
Member

Would we want to add a config object to every component upfront (so that the interface exists, even if it's not being used yet), or only to the components as-and-when they have a reason to need it?

@36degrees
Copy link
Contributor

Does this also include being able to pass config via initAll, or should that be a separate story?

@vanitabarrett
Copy link
Contributor Author

@36degrees I think I imagined it all being part of this story... I don't think the work would be too big to do in one, but if it turned out that way we could split it up. I'll expand the "Done when" section a bit at least to make it clear it's intended to include both

@36degrees
Copy link
Contributor

It's possible to pass a config object to a component via init() and initAll()

Based on this discussion, I think we've agreed that config will be passed to the constructor rather than the init function, which also matches the example in the proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
3 participants