Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Commit 459662e

Browse files
authored
Merge pull request #149 from smfoote/owner
Move `getOwner` out of component manager
2 parents 6b6c4a0 + 45d3df5 commit 459662e

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

packages/@glimmer/application/src/environment.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
import { Opaque } from '@glimmer/util';
1111
import {
1212
getOwner,
13-
setOwner
13+
setOwner,
14+
Owner
1415
} from '@glimmer/di';
1516
import Iterable from './iterable';
1617
import { Program } from '@glimmer/program';
@@ -77,4 +78,12 @@ export default class Environment extends GlimmerEnvironment {
7778

7879
return new Iterable(ref, keyFor);
7980
}
81+
82+
getOwner(): Owner {
83+
return getOwner(this);
84+
}
85+
86+
setOwner(obj: Object, owner: Owner): void {
87+
setOwner(obj, owner);
88+
}
8089
}

packages/@glimmer/component/src/component-manager.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
getOwner,
3-
setOwner,
4-
Owner
5-
} from "@glimmer/di";
1+
import { Owner } from "@glimmer/di";
62
import {
73
Bounds as VMBounds,
84
ComponentManager as IComponentManager,
@@ -33,7 +29,7 @@ export class ComponentStateBucket {
3329
public component: Component;
3430
private args: CapturedArguments;
3531

36-
constructor(definition: DefinitionState, args: CapturedArguments, owner: Owner) {
32+
constructor(definition: DefinitionState, args: CapturedArguments, owner: Owner, env: Environment) {
3733
let componentFactory = definition.ComponentClass;
3834
let name = definition.name;
3935

@@ -44,7 +40,7 @@ export class ComponentStateBucket {
4440
args: this.namedArgsSnapshot()
4541
};
4642

47-
setOwner(injections, owner);
43+
env.setOwner(injections, owner);
4844
if (componentFactory) {
4945
this.component = componentFactory.create(injections);
5046
}
@@ -121,8 +117,8 @@ export default class ComponentManager implements IComponentManager<ComponentStat
121117
// Only create a state bucket if the component is actually stateful. We can
122118
// skip this for template-only components, which are pure functions.
123119
if (definition.ComponentClass) {
124-
let owner = getOwner(this.env);
125-
return new ComponentStateBucket(definition, args.capture(), owner);
120+
let owner = this.env.getOwner();
121+
return new ComponentStateBucket(definition, args.capture(), owner, this.env);
126122
}
127123
}
128124

0 commit comments

Comments
 (0)