-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
(route-task) option? #89
Comments
@Luiz-N I'm sorry it's taken me so long to respond. I suppose that's a good idea given how many people use ember-route-action-helper. One reason I've hesitated on something like this is that it's already a lot easier to pass tasks around than it is to pass actions around (you can just pass a reference to the task to the controller rather than have to use (hoping for some other feedback from people who also think it's a good idea) |
IMO, might be worth the wait to see the RFC for routable components first. In the previous one, I think they were also passing args to the route component similar to |
I would really like to see this be a thing. |
it's probably going to bite me down the road. But right now I'm giving this a try. setupController() {
this._super(...arguments);
this.TASK.taskFn = this.TASK.taskFn.bind(this);
set(this.controller, 'TASK', this.TASK);
}, where |
I've created a quick PoC for a Give it a try and feel free to open issues for feedback! :) |
In the example shown in the README, I use {{#with (route-task "taskOnApplicationRoute" "Freddie") as |task|}}
{{#if task.isIdle}}
<button onclick={{perform task "Morecurry"}}>
Perform taskOnApplicationRoute
</button>
{{else}}
<button onclick={{cancel-all task}}>
Cancel taskOnApplicationRoute
</button>
Running taskOnApplicationRoute
{{/if}}
<br>
task.last.value: {{task.last.value}}<br>
task.last.error: {{task.last.error}}<br>
{{/with}} Or even better, only use {{task-aware-button
task=(route-task "deleteUser" model)
idleLabel=(concat "Delete " model.name)
runningLabel="Cancel deletion"
}} |
hey @machty impressive addon. An example of passing in a task directly to a component like you did here would be great to have in the docs. (Happy to help with that) Also, I was wondering if it would be possible to define a task in a route then be able to pass that down to child components. Essentially a e-c version of route-action... (route-task) perhaps?
I haven't tried this but could it be possible in the short term to define the tasks in a route then have actions that simply return the raw task. This way one could use route-action closures that simply point to a route defined task?
The text was updated successfully, but these errors were encountered: