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

nearestOfType marked private? #12110

Closed
raycohen opened this issue Aug 15, 2015 · 8 comments
Closed

nearestOfType marked private? #12110

raycohen opened this issue Aug 15, 2015 · 8 comments

Comments

@raycohen
Copy link
Contributor

In 6e1ad90 nearestOfType was marked as private.

On a quick search I could not find anything internal to ember accessing nearestOfType beyond the tests explicitly testing it.

nearestOfType seems to go against the desire for components to be encapsulated. However I have run across a few addons that use it.

It seems like it should either be marked as public or become deprecated. What is the future for this method?

@rwjblue
Copy link
Member

rwjblue commented Aug 15, 2015

I would much prefer the contextual component/helpers RFC's concepts to allow nested components to have access to their relative parents vs traversing up the tree to find the nearest of a given type.

For example, I would prefer something like the following:

{{#form-for model as |f|}}
  {{f.input 'firstName'}}
{{/form-for}}

Where because it was invoked off of f, the input can be aware which instance of form-for it belongs to.


Anyways, that isn't really the point of this issue (or maybe it does show the potential future if we can make it all happen). I am OK with it being marked @public, but my goal is to ultimately make it useless (sometime during the 2.x cycle) so we can then deprecate it.

@rwjblue
Copy link
Member

rwjblue commented Aug 15, 2015

The above is referring somewhat to the ideas of #10244 and emberjs/rfcs#64.

@mmun
Copy link
Member

mmun commented Aug 15, 2015

nearestOfType is still useful for some things (it's discussed in that rfc)

@koemeet
Copy link
Contributor

koemeet commented Aug 15, 2015

@mmun Indeed, I use it too and it is very helpful. For composable components it is very neat to have it traverse to the parent component by type instead of manualy recursing on parentView. It is very little code, that is quite usefull to me.

@mmun
Copy link
Member

mmun commented Aug 15, 2015

@steffenbrem I think you'll find that what @rwjblue suggested is even better in almost all cases.

@raycohen
Copy link
Contributor Author

while it isn't as nice as the contextual components rfc, I've been associating parent and child components by emitting this from the parent and passing it down, for example:

{{#radio-group selected=currentColor name="color" disabled=isDisabled as |group|}}
  {{#radio-button group=group value="red"}} Red {{/radio-button}}
  {{#radio-button group=group value="blue"}} Blue {{/radio-button}}
{{/radio-group}}

Ember Sortable uses this approach rather than nearestOfType

@rwjblue
Copy link
Member

rwjblue commented Aug 15, 2015

@raycohen - Yep, that is a great solution (if a little more verbose) until this lands.

Still: 👍 on marking as public. Would merge. :)

@rwjblue
Copy link
Member

rwjblue commented Aug 16, 2015

Closed by #12111.

@rwjblue rwjblue closed this as completed Aug 16, 2015
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

4 participants