DockYard/ember-route-action-helper

add `this.sendRouteAction()`

Opened this issue · 2 comments

For components that are JS heavy without a template, they currently use this.sendAction() to send actions. Perhaps an analogous this.sendRouteAction() from this lib would be appropriate.

In the issue linked above, I've raised some concerns that are relevant to this discussion as well, so I'll cross post them here.

In my opinion, this generally isn't a good design pattern. I would much rather prefer to explicitly pass the route action as an attribute:

{{my-component action=(route-action "actionName")}}

Just by looking at the component invocation in the template, the user should be able to judge what's going in and what's coming out of a component (DDAU). This way components remain completely agnostic and make no assumptions about the environment they are invoked in.

Calling routeAction inside a component is really non-transparent and promotes an unhealthy invisible entanglement.

On the other hand, you can already call (route-action) in the component's template.

Because of that, I think we can go ahead and implement it. Just because it's there, doesn't mean you have to use it. 😜

This function would be really nice, for example in the application-route we have a methode to refresh the model. If we need to refresh the model inside a component, it would be cleaner to call directly this.sendRouteAction() instead of passing it explicily