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

Improve child component registration, reduce coupling #31

Open
ElliotNB opened this issue Oct 8, 2019 · 0 comments
Open

Improve child component registration, reduce coupling #31

ElliotNB opened this issue Oct 8, 2019 · 0 comments

Comments

@ElliotNB
Copy link
Owner

ElliotNB commented Oct 8, 2019

Today, to register child components, we must do something like this:

this.registerChild(childComponent);

The template of the parent component might then look something like this:

<div>
    <h1>Hello world!</h1>
    <child-component-name></child-component-name>
</div>

The trouble is that child-component-name is defined inside the JS file for the child component -- the tagName. It creates a hard dependency between the two classes. It is possible for the parent component to overwrite that component name by passing in the tagName to the child component constructor -- but that's cumbersome and not very convenient. In practice, the parent component just ends up using whatever the child component defined as their tagName.

If the child component gets refactored at a later date and gets a new tagName, then it would break any other component that uses it.

As a possible solution I think we should remove tagName from the Nimbly component configs and allow components to specify the name of a child component when it's being registered.

So the registerChild method would become something like this:

this.registerChild(childComponent, "component-name");

This will get a bit more complicated for registering child components for repeatable sections, will need to discuss with the team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant