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

Component helper should be able to bind modifiers #18695

Closed
mehulkar opened this issue Jan 24, 2020 · 3 comments
Closed

Component helper should be able to bind modifiers #18695

mehulkar opened this issue Jan 24, 2020 · 3 comments

Comments

@mehulkar
Copy link
Contributor

I would like to be able to do something like this:

{{component "foo" (modifier on "click" this.clickHandler)}}

The primary reason for this is for contextual components to be able to yield back a prepared/curried component to its block.

Example

A component that allows block form and yields components cannot provide an experience that is equivalent to inline form.

The only alternative is to yield @clickHandler back to the block and expect the consumer to apply the modifier as well.

{{#let component "foo" someArg=@someArg as |Foo|}}
  {{#if (has-block)}}
    {{yield (hash foo=Foo)}}
  {{else}}
    <Foo {{on "click" @clickHandler}} />
  {{/if}}
{{/let}}
@rwjblue
Copy link
Member

rwjblue commented Jan 24, 2020

This was addressed by emberjs/rfcs#432, and is "in the works" (the underlying feature is unblocked by the glimmer-vm upgrade that landed in 3.17 cycle).

@rwjblue rwjblue closed this as completed Jan 24, 2020
@chriskrycho
Copy link
Contributor

A note here, for anyone else who stumbles on it: (modifier) is a necessary but insufficient element to address what @mehulkar was originally asking for. You also need a higher-order component which can be yielded. With <template>, this becomes relatively straightforward to do by wrapping it locally; but we still need emberjs/rfcs#497 or emberjs/rfcs#593 to make that kind of wrapping viable.

@NullVoxPopuli
Copy link
Sponsor Contributor

This is much easier in GJS, you'd do this:

const Foo = <template>
  <SomeComponent {{aModifier}} ...attributes>
     {{yield}}
  </SomeComponent>
</template>


export default <template>
  {{yield (component Foo)}}
</template>

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