-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE ember-container-inject-owner] Inject
owner
instead of `con…
…tainer` during `lookup`. This change represents the final brick needed to wall off the `Container` as fully private. The Container no longer injects itself into every object that it looks up. Instead, it uses the new `setOwner` helper to inject the "owner", which can then be retrieved from any object using the new `getOwner` helper. The current net effect is that an app instance is injected into every looked up object instead of that app instance's container. This provides clean, public access to methods exposed by the app instance's ContainerProxy and RegistryProxy methods. It also guarantees that the only supported path to get to a Container or Registry is through a proxied method. This guarantee is important because it allows for owner-specific logic to be placed in proxy methods. In the future, other classes, such as Engine (coming soon), may mix in ContainerProxy and thus have the potential to be "owners". This work is behind the `ember-container-inject-owner` flag. Without this flag enabled, the Container will continue to inject itself directly into objects that it instantiates (as `container`).
- Loading branch information
Showing
93 changed files
with
1,799 additions
and
1,675 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import EmberObject from 'ember-runtime/system/object'; | ||
import Registry from 'container/registry'; | ||
import RegistryProxy from 'ember-runtime/mixins/registry_proxy'; | ||
import ContainerProxy from 'ember-runtime/mixins/container_proxy'; | ||
|
||
export default function buildOwner(props) { | ||
let Owner = EmberObject.extend(RegistryProxy, ContainerProxy, { | ||
init() { | ||
this._super(...arguments); | ||
const registry = this.__registry__ = new Registry(); | ||
this.__container__ = registry.container({ owner: this }); | ||
} | ||
}); | ||
return Owner.create(props); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.