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

Ability to spread an object to bindables #1477

Closed
brandonseydel opened this issue Jul 11, 2022 · 5 comments · Fixed by #1965
Closed

Ability to spread an object to bindables #1477

brandonseydel opened this issue Jul 11, 2022 · 5 comments · Fixed by #1965

Comments

@brandonseydel
Copy link
Member

brandonseydel commented Jul 11, 2022

🙋 Feature Request

When looping through sometimes I would like to spread the object I am looping through on the component rather than oen by one

🤔 Expected Behavior

        <k-button  repeat.for="action of actions" ...action>${action.content}</k-button>

😯 Current Behavior

        <k-button color.bind="action.color"
                          size.bind="action.size"
                          type.bind="action.type" 
                          epeat.for="action of actions">${action.content}</k-button>

💁 Possible Solution

Allow some form of spread to bind al properties from object that match

🔦 Context

💻 Examples

@Vheissu
Copy link
Member

Vheissu commented Jul 22, 2022

Yes, please. Most of my Aurelia applications are littered with redundant bind statements mapping to property names in objects.

@bigopon
Copy link
Member

bigopon commented Jul 25, 2022

One question we haven't answered since the first efforts long ago is what happens when a new property is added. If we are to ignore, this feature is easy to implement but there will be mis-expectation. If we are to subscribe & notify, we don't have a way to subscribe in a proper way.

Also, it's unclear what to expect when spreading a mixture of bindables and non-bindables on an object.

Says there's a custom element el with bindables value, and we have this templae

<let object.bind="{ value: 1, id: 'hello' }"></let>
<el ...object></el>

Where should the properties in the object go? Should both value and id go to the view model, or the host element? or should value go to the view model while id goes to the host element?

@brandonseydel
Copy link
Member Author

@bigopon - only bindables unless there is a @bindable({type:Object}) maybe?

@brandonseydel
Copy link
Member Author

@bigopon - I was only thinking the spread to work on CE not native elements as well (for first phase)

@bigopon
Copy link
Member

bigopon commented Jul 26, 2022

@bigopon - I was only thinking the spread to work on CE not native elements as well (for first phase)

If we are to do this, we can also do spreading based on host: if a CE host then spread into the view model, and if not, spread into the host element.
It'll solve some of the ergonomic issues. Though it won't solve the mis-expectation with the added properties, at least yet.

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

Successfully merging a pull request may close this issue.

3 participants