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

setting name=null breaks {{from-elsewhere}} #4

Open
grapho opened this issue Oct 3, 2016 · 6 comments
Open

setting name=null breaks {{from-elsewhere}} #4

grapho opened this issue Oct 3, 2016 · 6 comments

Comments

@grapho
Copy link

grapho commented Oct 3, 2016

In this twiddle, I am binding a value to name in a {{from-elsewhere

It appears that, if the binding becomes null it will break the helper, even if you set name back to a valid string.

the only way the helper continues to work is if you are consuming the name binding somewhere else in the template.

this is confusing because the binding i am using is not a computed property.. so im not quite sure why i need to consume it for the helper to work?

https://ember-twiddle.com/dd9c2e80c52c98eb3860b132abc74c17?openFiles=templates.application.hbs%2C

you can reproduce the behavior in this twiddle if you remove the {{activeComponent}} at the top of application.hbs

@grapho
Copy link
Author

grapho commented Oct 4, 2016

You can label this as a low-priority issue... my current solution is to just wrap the helper in an {{#if to guard against name being null.

@ef4
Copy link
Owner

ef4 commented Oct 4, 2016

We should fix this so it doesn't break on name=null.

But your example seems like a weird use case for this add-on. I am curious what you are trying to do and why the regular {{component ...}} helper can't do it.

@grapho
Copy link
Author

grapho commented Oct 4, 2016

Elsewhere allows me to have much more varied components render in the same place... where {{component}} helper narrows you in to a more uniform component invocation.

for instance if two components have completely different attrs and/or actions... the {{component}} helper would force me to pass all the attrs in all at once...
And what about two components that have overlapping attrs content or action for instance.. but they need to be bound to different things? {{component}} helper again would force me to use some sort of {{if}} business.. super messy after a while.

Elsewhere, so far has been the cleanest solution for me and the specific UI that I am building... I have an uncommon use case perhaps.. but a valid one as far as i can see.

At any rate, if the {{from-elsewhere would gracefully just render nothing or even just an empty <div> by default, that should be acceptable, i would think?

@ef4
Copy link
Owner

ef4 commented Oct 4, 2016

But you still must have all those other invocations in your template somewhere anyway. For example:

{{#if activeComponent}}
  {{from-elsewhere name=activeComponent}}
{{/if}}

{{to-elsewhere named="general-info" send=(component "general-info" info=info action=(action 'infoAction'))}}
{{to-elsewhere named="product-info" send=(component "product-info" product=product)}}

Is equivalent to this, which is both simpler and faster:

{{#if (eq activeComponent "general-info")}}
  {{general-info info=info action=(action 'infoAction') }}
{{else if (eq activeComponent "product-info") }}
  {{product-info product=product}}
{{/if}}

@grapho
Copy link
Author

grapho commented Oct 4, 2016

ah but it is more complex than that.

imagine a template divided into quadrants. each quadrant has tabbed panels. then imagine a large list of component invocations. those components can render into any one of those quadrants in any configuration, via the tabbed navigation, dragging and dropping tabs into other quadrants also "moves" said component into the new quadrant.

i guess the main thing is "any component, anywhere" as easily as possible without duplicating invocations.

fwiw.. i already have this UI finished.. using the {{component}} helper successfully... but i ran into some walls when adding more and more features into each component.

oh and also ( :p :p ) I've already converted the whole thing to ember-elsewhere and it works great!

@ef4
Copy link
Owner

ef4 commented Oct 5, 2016

👍

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

2 participants