Conversation
|
@NullVoxPopuli |
| export default class SendMessage extends Component { | ||
| @action | ||
| sendMessage(messageType) { | ||
| async sendMessage(messageType) { |
There was a problem hiding this comment.
I know some work supporting async/await landed into backburner and Ember in 3.x, but I'm not sure if FW core is encouraging this in app code yet. I've queried a few people for clarification.
Regardless, I'm not sure why this action is async... Simply to provide an example that it is possible?
There was a problem hiding this comment.
I've been using async/await everywhere in emberclear, and haven't ran into issues. 🤷♂️
I think the the name implies that there is going to be some interaction with a backend, so I would expect it to be async :)
| Note that while Ember currently permits you to add an action to any DOM element, not all DOM elements are eligible to receive focus, according to HTML standards. | ||
| Note that while Ember currently permits you to add an action to any DOM | ||
| element, not all DOM elements are eligible to receive focus, according to | ||
| HTML standards. |
There was a problem hiding this comment.
This Note is pretty confusing. As a reader I'm not sure what this comment (something something focus) has to do with actions on non-clickable elements.
This is likely trying to nudge the user to think about accessibility? Can it be structured so that a first time using coming to this section can get the information they expected before that consideration distracts them?
There was a problem hiding this comment.
This Note is pretty confusing.
yeah, I struggled with it a bit, too.
This is likely trying to nudge the user to think about accessibility?
I think so. I've primarily only used Chrome and FireFox, so I haven't run in to any issues with browsers not letting things be clickable. I wonder if this text is counting a screen reader or other a11y tool as a browser.
There was a problem hiding this comment.
Not sure what to do about these notes -- kinda out of scope for this Pr, but if someone else wants to tackle it / open an issue for it, be my guest!
|
Could/should the docs provide a migration guidance for the For example, given this code: actions: {
update(value) {
console.log(value);
}
}Is this the recommended replacement? @action
update({ target: { checked, value } }) {
console.log(checked || value);
}And is there a path for You'd have to create an action in the component that updates AFAICT, the {{on}} RFC didn't touch on that? @pzuraq |
|
@cvx I believe the first few examples should be the preferred form. Currently, we don't have a path to a direct replacement for
Basically, these APIs are convenient in that they are terse, but they are not easy to teach, and do not have much utility unless they are used together. We realized through the design process that what we really want here is some form of closures: Something along these lines. However, this is a huge lift, and adds a large amount of complexity to both Glimmer from an implementation perspective and templates from a language design persective, so I'm not sure if this is a direction we want to go yet. I think in the meantime, it would be best to make a custom helper that handles common use cases like this, where it would be inconvenient to create an action handler. call it <input {{on "input" (pickAndSet this "query" "target.value")}} />This would pick the value off of whatever is passed to it and set it. Then at least the two actions are related to each other lexically, and can tell the users that they are related just by reading it. You could use a template transform to mimic the |
guides/release/templates/actions.md
Outdated
|
|
||
| You can then add this action to an element using the | ||
| [`{{action}}`](https://api.emberjs.com/ember/release/classes/Ember.Templates.helpers/methods/action?anchor=action) | ||
| `@action` binds the `this` of `toggleBody()` to the instance of the class, allowing access the component's other properties when invoked. Without the decorator, `this.isShowingBody` in `toggleBody()` is undefined. For more information on `this` [Understanding Javascript Function Invocation and this](https://yehudakatz.com/2011/08/11/understanding-javascript-function-invocation-and-this/) |
There was a problem hiding this comment.
Thanks @NullVoxPopuli and @locks for talking this through with me. I think this hits the key terms (binds, class) while also, with the second sentence, explaining in a more quotidian way why @action is needed!
|
|
||
| - **Contextual Components**, which can be used dynamically to pass components | ||
| around as values, and allow them to be invoked in different locations. No newline at end of file | ||
| around as values, and allow them to be invoked in different locations. |
There was a problem hiding this comment.
that comma before "and" is not needed and causes confusion.
| @@ -142,4 +142,5 @@ In the following guides we'll talk about: | |||
| which Ember fully supports | |||
There was a problem hiding this comment.
While at it, this should have a period at the end to follow the style of the rest of this list.
|
Thank you @NullVoxPopuli and reviewers! If anyone wants to extend upon this work or make additional fixes, I'm happy to help get more PRs merged in! |

related info: https://www.pzuraq.com/ember-octane-update-action/