You can yield an action from your component, let me explain with a quick example. Let’s say you have a component for “tasks-list” which has children components of “task-item”.
The tasks-list component can yield an action:
1 |
{{yield (action 'save')}} |
Which you can pass into your task-item components
1 2 3 |
{{tasks-list as |listSaveAction|}} {{task-item save=listSaveAction}} {{/tasks-list}} |
Your task-item component can now call the tasks-list yielded action
1 2 3 |
someActionOnTaskItem() { this.attrs.save(); //this calls the tasks-list action } |
Tip inspired by: https://til.hashrocket.com/posts/0ac953d2b9-yielded-closure-actions-as-an-api-for-a-component