Conversation
pzuraq
left a comment
There was a problem hiding this comment.
Looking great so far! Added some comments about where I think this can be fleshed out a bit. I think the next section to start on would be the "How we teach this" section, since that one also doesn't need detailed design work or to understand the internals or anything.
|
|
||
| ## Motivation | ||
|
|
||
| The reason for doing this is to allow less verbose component templates where the verbosity only makes the template harder to read. |
There was a problem hiding this comment.
So I tend to be a bit more on the formal side here, but I think of the summary and the motivation as independent sections. Right now it reads like the summary is the first part of this section - if you remove it, this sentence doesn't make sense any more.
For instance, you could replace this with:
"Spreadable arguments will allow for less verbose component templates, especially where the verbosity..."
And then the sentence (and the section) stand on their own a bit more. Another option would be to start with the current state of the world:
"Currently, users must do x, y, and z in their applications. This is bad for reasons. Spreadable arguments would allow users to solve these problems in a better way..."
| A possible example in the wild could be | ||
| [ember-power-select](https://github.com/cibernox/ember-power-select/blob/master/addon/templates/components/power-select.hbs). | ||
| This component has to explicitely pass on many arguments to its child components. With "splarguments" half or more of this template could | ||
| be cut down. |
There was a problem hiding this comment.
So I think a very important point to make here is that this also has a knock-on effect which reduces maintenance of components. For instance, currently if I want to wrap a component, I have to explicitly forward every argument:
This is already super verbose and pretty bad, but now let's say that I add @arg3 to Foo - that means that I have to go through and update every single component template that is wrapping Foo.
I think a great example of this would be a Button component, with a bunch of wrapping button "types":
This would be a great pattern! No need to subclass the Button component, you can just have a bunch of TO-components that wrap it and provide the @type - until you need to start adding other arguments, like @onClick and so on. Now you have 3 files to go update, which is a giant pain.
There was a problem hiding this comment.
Updated to include these examples. What do you think?
pzuraq
left a comment
There was a problem hiding this comment.
Looks great, this is fantastic so far! 😄 Love the changes, it reads very well. Let me know if you want help with the detailed design/learning sections!
|
@pzuraq I would love help. Its finals season for me so my time is more limited than usual. I was planning on working on this a bit on the weekend bit I definitely need help in the detailed design section as well as any other section you can help with :) |
|
I'd link to support you. Should I be a contributor to update the RFC? |
|
@tleperou I am open to PRs to this branch :) |
|
This is more a question than a suggestion. Given that argument are usually passed with curly braces (unless they are strings), would it make more sense to splat inside curly braces? Example: Another reason is that, visually, |
|
@cibernox That looks nice. Chris and I are planning to chat about this in the next few days. Sounds good :) |
|
@cibernox I agree that spreading for arguments and attributes needs a way to be syntactically distinct. I actually realized this during the discussion on this thread, where they were suggesting adding a way to spread objects other than the attributes and arguments object, and I think it's very important that we design this feature in such a way that we don't box ourselves into a corner should we decide to add arbitrary spreading in the future. So, with that in mind, I think there are two syntactically distinct options so far, including yours: If we consider the future where we are able to spread arbitrary objects, they look like: Both have their drawbacks and issues. I'm personally slightly in favor of variant 2 for a couple reasons:
Definitely open to more suggestions here, we'll probably pick one and list the others as an alternative! |
|
Just stumbled across this thread again, great work - totally in favour of it! Just to clarify, in my pre-RFC which @pzuraq linked above, I'm not suggesting arbitrary object splatting, but rather I'm suggesting that we explore some syntax to allow "breaking off" some value from
I don't want to derail this PR (so if anyone would like to reply to me, please reply to me on this thread), but just wanted to clarify that the above is the end goal I was seeking to achieve in my pre-RFC - not necessarily splatting of arbitrary objects. And I'm also not in favour of, nor am I suggesting any special syntax/arbitrary splattable attribute objects, (as suggested above) which would require this to be "routed" at the call site, since it breaks Liskov Substitution Principle with standard HTML elements - for example, this is definitely not what I'm suggesting: 😉 |
|
@lougreenwood I think that what you are not suggesting sounds pretty nice 😅 A possibility for arguments, and maybe attributes, is this: This looks a bit weird though but could potentially do what you are asking. |
RFC: TypeScript Adoption Plan
Amend RFC 0724 to include template type checking
RFC: Semantic Versioning for TypeScript Types
Co-authored-by: Chris Krycho <hello@chriskrycho.com>
Co-authored-by: Chris Krycho <hello@chriskrycho.com>
Co-authored-by: Chris Krycho <hello@chriskrycho.com>
Co-authored-by: MrChocolatine <47531779+MrChocolatine@users.noreply.github.com>
Fix stage for accepted RFCs
Advance RFC emberjs#821 to Stage Released
Advance RFC emberjs#889 to Stage Ready for Release
Advance RFC emberjs#236 to Stage Released
Advance RFC emberjs#889 to Stage Released
Advance RFC emberjs#756 to Stage Recommended
Co-authored-by: Peter Wagenet <peter.wagenet@gmail.com>
Co-authored-by: Peter Wagenet <peter.wagenet@gmail.com>
Deprecate implicit record loading in Ember Route
|
@ef4 Did you merge upstream main? Might be better to rebase? Though maybe we don't do that in the Ember repos? |
Rendered