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

Restore child components configured as true #2424

Closed

Conversation

misteroneill
Copy link
Member

Previously, child components could be configured using true, false, or an object. Support for true appears to have been lost in the transition to 5.0. This restores that capability.

@dmlap
Copy link
Member

dmlap commented Aug 3, 2015

lgtm

@heff
Copy link
Member

heff commented Aug 3, 2015

The major changes around this were still in 4.x, so I'm surprised this works in 4.12 and not 5.x. I think I felt this wasn't needed anymore after moving to children arrays (#1599 is the closest PR I can find). Still seems like since you can just use an empty object that it'd be nice to deprecate this instead, but I'm fine either way if you have a good reason to keep it.

@misteroneill
Copy link
Member Author

I'm gonna close this as children should be an array going forward.

@misteroneill misteroneill deleted the restore-options-boolean branch August 3, 2015 19:18
@misteroneill misteroneill restored the restore-options-boolean branch August 3, 2015 20:05
@misteroneill
Copy link
Member Author

Alright, I'm reopening this now that I understand the whole situation better.

An empty object does work, but it doesn't really feel intuitive to me - especially when false is a possibility.

Additionally, I want to raise (re-raise?) the issue that having children support either an array or an object leads to all sorts of unclear situations. It means a developer needs to inspect the various component classes to see what their default configurations might be and construct objects or arrays as necessary to either work with or around the implicit deep merge of objects but not arrays.

@misteroneill misteroneill reopened this Aug 3, 2015
Previously, child components could be configured using `true`, `false`,
or an object. Support for `true` appears to have been lost in the
transition to 5.0. This restores that capability.
@heff
Copy link
Member

heff commented Aug 3, 2015

An empty object does work, but it doesn't really feel intuitive to me - especially when false is a possibility.

Works for me. I think true would really only get used if you were overriding a deeper false in the chain, or if someone just assumed that true was needed to include a child, which supports your intuitive comment.

Additionally, I want to raise (re-raise?) the issue that having children support either an array or an object leads to all sorts of unclear situations.

Originally children was always an object. It allowed you to pass down options to any depth of children if needed.

playerOptions = {
  children: {
    controlBar: {
      children: {
        volumeMenuButton: {
           vertical: true
        }
      }
    }
  }
}

Then #1070 and #1093 happened and we added the option to use an array, specifically to control ordering. We didn't immediately switch all children objects to arrays because that would have been a pretty big breaking change and also arrays didn't allow you to pass options to children.

Then #1599 happened and we can add options to children defined with an array. I believe it should work for deeper children too.

playerOptions = {
    controlBar: {
        volumeMenuButton: {
           vertical: true
        }
    }
}

This does not help if you have two children of the same type that need different options, but I've yet to see a case of that, and if you need that you can rebuild the array. children: [ { name: 'sameComponent', foo: true }, { name: 'sameComponent', foo: false }].

I don't think we should remove the object option just yet but if we want to mark it as deprecated I'm ok with that. I think the array version is the right way going forward. Anyone else want to weigh in?

@dmlap
Copy link
Member

dmlap commented Aug 3, 2015

Deprecate the option-object but keep it around for 5.x sounds like the right path to me.

@misteroneill
Copy link
Member Author

@heff Thanks a ton for the historical clarification here! I don't have any strong opinions here, but I do prefer the array approach because it allows better control of final structure/ordering.

I'll take it upon myself to document the component children changes for 5.0 and deprecation of the object option.

@heff
Copy link
Member

heff commented Aug 6, 2015

Ok cool. I guess this one is good to pull in though, yeah?

@gkatsev
Copy link
Member

gkatsev commented Aug 6, 2015

Somewhat related, can we allow users to add in a reference to a component directly in the array and initialize it as needed? :)

@heff
Copy link
Member

heff commented Aug 6, 2015

@gkatsev not sure I follow completely. Are you just saying allow for already-initialized components in the array? Or can you give an example?

@gkatsev
Copy link
Member

gkatsev commented Aug 7, 2015

Basically.

let AConstructorForVjsToInitialize = function() {
 this.color = blue;
};
let someButtonThing = new Button();
// ...
children: ['foo', someButtonThing, AConstructorForVjsToInitialize, 'baz']

This should also apply for the techOrder array :)

Regardless, it definitely should not hold up this PR.

@dmlap
Copy link
Member

dmlap commented Aug 10, 2015

Seems like this one has gotten signed-off but I'll throw in my "LGTM" as well.

@dmlap dmlap closed this in 1bf6489 Aug 10, 2015
@misteroneill misteroneill deleted the restore-options-boolean branch August 11, 2015 14:06
@heff
Copy link
Member

heff commented Aug 12, 2015

@gkatsev re: children: ['foo', someButtonThing, AConstructorForVjsToInitialize, 'baz']

someButtonThing may already work. If not I don't see why it couldn't be added, though also options couldn't be passed to it from the parent if it's already initialized.

AConstructorForVjsToInitialize, if we're talking about non-Components, would be difficult since the child init process expects a handful of component functions to be there.

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

Successfully merging this pull request may close these issues.

4 participants