Skip to content

Commit

Permalink
Merge pull request #318 from maxfierke/mf-fix_nested_encapsulated_tas…
Browse files Browse the repository at this point in the history
…k_injection

Ensure tasks are assigned to a container
  • Loading branch information
maxfierke committed Sep 24, 2019
2 parents 047caf7 + 7b291b1 commit 42d7b9b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion addon/-task-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { scheduleOnce } from '@ember/runloop';
import { addObserver } from '@ember/object/observers';
import { addListener } from '@ember/object/events';
import EmberObject from '@ember/object';
import { getOwner } from '@ember/application';
import { getOwner, setOwner } from '@ember/application';
import { default as TaskInstance, getRunningInstance } from './-task-instance';
import {
PERFORM_TYPE_DEFAULT,
Expand Down Expand Up @@ -383,6 +383,8 @@ export const Task = EmberObject.extend(TaskStateMixin, {
_performType: performType,
});

setOwner(taskInstance, getOwner(this.context));

if (performType === PERFORM_TYPE_LINKED) {
linkedObject._expectsLinkedYield = true;
}
Expand Down
5 changes: 2 additions & 3 deletions tests/dummy/app/task-injection-test/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ export default Controller.extend({

myTask: task({
fun: service(),
perform: function * () {
*perform() {
let value = yield this.get('subtask').perform();
return `${this.get('fun.foo')}-${value}`;
},

subtask: task({
fun: service(),
wat: 2,
perform: function * () {
*perform() {
return this.get('fun.foo') * this.wat;
},
}),
}),
});

0 comments on commit 42d7b9b

Please sign in to comment.