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

Allow helper usage in JS land #7

Closed
buschtoens opened this issue Aug 6, 2017 · 2 comments
Closed

Allow helper usage in JS land #7

buschtoens opened this issue Aug 6, 2017 · 2 comments

Comments

@buschtoens
Copy link
Owner

Based on DockYard/ember-route-action-helper#64:

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.

The helper could be modified, so that there's a named routeTask export with a signature similar to invokeAction:

import { routeTask } from 'ember-route-task-helper/helpers/route-task'; 

export default class extends Component {
  click() {
    const curriedRouteTask = routeTask(this, 'taskName', 'Freddie', 'Morecurry');
    curriedRouteTask.perform('argument1', 'argument2');
  }
}

The above helper could also be re-exported as an export from 'index.js' for easier access.

@buschtoens
Copy link
Owner Author

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

{{my-component taskName=(route-task "taskName" "Freddie" "Morecurry")}}

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 routeTask inside a component is really non-transparent and promotes an unhealthy invisible entanglement.

I'm interested in more opinions.

@buschtoens
Copy link
Owner Author

buschtoens commented Aug 6, 2017

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

I'm just gonna go ahead and implement it. Just because it's there, doesn't mean you have to use it. 😜

@buschtoens buschtoens mentioned this issue Aug 6, 2017
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

1 participant