ember-source 4.5.0-alpha.4 → 4.5.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -4
- package/blueprints-js/-addon-import.js +48 -0
- package/blueprints-js/acceptance-test/mocha-files/tests/acceptance/__name__-test.js +24 -0
- package/blueprints-js/acceptance-test/mocha-rfc-232-files/tests/acceptance/__name__-test.js +13 -0
- package/blueprints-js/acceptance-test/qunit-files/tests/acceptance/__name__-test.js +12 -0
- package/blueprints-js/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.js +13 -0
- package/blueprints-js/component/files/__root__/__path__/__name__.js +3 -0
- package/blueprints-js/component/files/__root__/__templatepath__/__templatename__.hbs +1 -0
- package/blueprints-js/component-addon/files/__root__/__path__/__name__.js +1 -0
- package/blueprints-js/component-class/files/__root__/__path__/__name__.js +3 -0
- package/blueprints-js/component-class-addon/files/__root__/__path__/__name__.js +1 -0
- package/blueprints-js/component-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +34 -0
- package/blueprints-js/component-test/mocha-files/__root__/__testType__/__path__/__test__.js +36 -0
- package/blueprints-js/component-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +38 -0
- package/blueprints-js/component-test/qunit-files/__root__/__testType__/__path__/__test__.js +31 -0
- package/blueprints-js/component-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +36 -0
- package/blueprints-js/controller/files/__root__/__path__/__name__.js +3 -0
- package/blueprints-js/controller-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +16 -0
- package/blueprints-js/controller-test/mocha-files/__root__/__testType__/__path__/__test__.js +18 -0
- package/blueprints-js/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +13 -0
- package/blueprints-js/controller-test/qunit-files/__root__/__testType__/__path__/__test__.js +12 -0
- package/blueprints-js/controller-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +12 -0
- package/blueprints-js/helper/files/__root__/__collection__/__name__.js +5 -0
- package/blueprints-js/helper/mu-files/__root__/__collection__/__name__.js +7 -0
- package/blueprints-js/helper-addon/files/__root__/__path__/__name__.js +1 -0
- package/blueprints-js/helper-test/mocha-0.12-files/__root__/__testType__/__collection__/__name__-test.js +26 -0
- package/blueprints-js/helper-test/mocha-files/__root__/__testType__/__collection__/__name__-test.js +28 -0
- package/blueprints-js/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +18 -0
- package/blueprints-js/helper-test/qunit-files/__root__/__testType__/__collection__/__name__-test.js +15 -0
- package/blueprints-js/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +17 -0
- package/blueprints-js/initializer/files/__root__/initializers/__name__.js +5 -0
- package/blueprints-js/initializer-addon/files/__root__/__path__/__name__.js +1 -0
- package/blueprints-js/initializer-test/mocha-files/__root__/__testType__/__path__/__name__-test.js +28 -0
- package/blueprints-js/initializer-test/mocha-rfc-232-files/__root__/__testType__/__path__/__name__-test.js +31 -0
- package/blueprints-js/initializer-test/qunit-files/__root__/__testType__/__path__/__name__-test.js +25 -0
- package/blueprints-js/initializer-test/qunit-rfc-232-files/__root__/__testType__/__path__/__name__-test.js +37 -0
- package/blueprints-js/instance-initializer/files/__root__/instance-initializers/__name__.js +5 -0
- package/blueprints-js/instance-initializer-addon/files/__root__/__path__/__name__.js +1 -0
- package/blueprints-js/instance-initializer-test/mocha-files/__root__/__testType__/__path__/__name__-test.js +30 -0
- package/blueprints-js/instance-initializer-test/mocha-rfc-232-files/__root__/__testType__/__path__/__name__-test.js +32 -0
- package/blueprints-js/instance-initializer-test/qunit-files/__root__/__testType__/__path__/__name__-test.js +26 -0
- package/blueprints-js/instance-initializer-test/qunit-rfc-232-files/__root__/__testType__/__path__/__name__-test.js +39 -0
- package/blueprints-js/mixin/files/__root__/mixins/__name__.js +3 -0
- package/blueprints-js/mixin-test/mocha-files/__root__/__testType__/__name__-test.js +13 -0
- package/blueprints-js/mixin-test/mocha-rfc-232-files/__root__/__testType__/__name__-test.js +13 -0
- package/blueprints-js/mixin-test/qunit-files/__root__/__testType__/__name__-test.js +12 -0
- package/blueprints-js/mixin-test/qunit-rfc-232-files/__root__/__testType__/__name__-test.js +12 -0
- package/blueprints-js/route/files/__root__/__path__/__name__.js +9 -0
- package/blueprints-js/route/files/__root__/__templatepath__/__templatename__.hbs +2 -0
- package/blueprints-js/route-addon/files/__root__/__path__/__name__.js +1 -0
- package/blueprints-js/route-addon/files/__root__/__templatepath__/__templatename__.js +1 -0
- package/blueprints-js/route-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +15 -0
- package/blueprints-js/route-test/mocha-files/__root__/__testType__/__path__/__test__.js +17 -0
- package/blueprints-js/route-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +12 -0
- package/blueprints-js/route-test/qunit-files/__root__/__testType__/__path__/__test__.js +11 -0
- package/blueprints-js/route-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +11 -0
- package/blueprints-js/service/files/__root__/__path__/__name__.js +3 -0
- package/blueprints-js/service-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +16 -0
- package/blueprints-js/service-test/mocha-files/__root__/__testType__/__path__/__test__.js +18 -0
- package/blueprints-js/service-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +13 -0
- package/blueprints-js/service-test/qunit-files/__root__/__testType__/__path__/__test__.js +12 -0
- package/blueprints-js/service-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +12 -0
- package/blueprints-js/template/files/__root__/__path__/__name__.hbs +0 -0
- package/blueprints-js/test-framework-detector.js +60 -0
- package/blueprints-js/util/files/__root__/utils/__name__.js +3 -0
- package/blueprints-js/util-test/mocha-files/__root__/__testType__/__name__-test.js +11 -0
- package/blueprints-js/util-test/mocha-rfc-232-files/__root__/__testType__/__name__-test.js +11 -0
- package/blueprints-js/util-test/qunit-files/__root__/__testType__/__name__-test.js +10 -0
- package/blueprints-js/util-test/qunit-rfc-232-files/__root__/__testType__/__name__-test.js +10 -0
- package/build-metadata.json +3 -3
- package/dist/ember-template-compiler.js +12 -5
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +1 -1
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +722 -1001
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/container/index.js +2 -2
- package/dist/packages/@ember/-internals/glimmer/index.js +33 -23
- package/dist/packages/@ember/-internals/metal/index.js +19 -7
- package/dist/packages/@ember/-internals/routing/lib/location/api.js +3 -3
- package/dist/packages/@ember/-internals/routing/lib/location/auto_location.js +5 -1
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +7 -6
- package/dist/packages/@ember/-internals/routing/lib/services/routing.js +9 -6
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +6 -9
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +4 -2
- package/dist/packages/@ember/-internals/routing/lib/utils.js +15 -25
- package/dist/packages/@ember/-internals/runtime/lib/compare.js +4 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +14 -15
- package/dist/packages/@ember/-internals/runtime/lib/mixins/action_handler.js +32 -44
- package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +1 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/comparable.js +7 -22
- package/dist/packages/@ember/-internals/runtime/lib/mixins/container_proxy.js +34 -46
- package/dist/packages/@ember/-internals/runtime/lib/mixins/enumerable.js +2 -15
- package/dist/packages/@ember/-internals/runtime/lib/mixins/evented.js +13 -57
- package/dist/packages/@ember/-internals/runtime/lib/mixins/mutable_enumerable.js +2 -16
- package/dist/packages/@ember/-internals/runtime/lib/mixins/observable.js +64 -134
- package/dist/packages/@ember/-internals/runtime/lib/mixins/promise_proxy.js +28 -86
- package/dist/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +59 -61
- package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +17 -24
- package/dist/packages/@ember/-internals/runtime/lib/system/array_proxy.js +59 -85
- package/dist/packages/@ember/-internals/runtime/lib/system/object.js +9 -2
- package/dist/packages/@ember/-internals/runtime/lib/system/object_proxy.js +3 -77
- package/dist/packages/@ember/-internals/utils/index.js +1 -1
- package/dist/packages/@ember/-internals/utils/types.js +1 -0
- package/dist/packages/@ember/-internals/views/lib/compat/attrs.js +1 -2
- package/dist/packages/@ember/-internals/views/lib/component_lookup.js +2 -2
- package/dist/packages/@ember/-internals/views/lib/mixins/action_support.js +3 -9
- package/dist/packages/@ember/-internals/views/lib/mixins/child_views_support.js +4 -6
- package/dist/packages/@ember/-internals/views/lib/mixins/class_names_support.js +13 -18
- package/dist/packages/@ember/-internals/views/lib/mixins/view_state_support.js +3 -2
- package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +57 -58
- package/dist/packages/@ember/-internals/views/lib/system/event_dispatcher.js +142 -120
- package/dist/packages/@ember/-internals/views/lib/system/utils.js +1 -1
- package/dist/packages/@ember/-internals/views/lib/views/states/destroying.js +1 -1
- package/dist/packages/@ember/-internals/views/lib/views/states/has_element.js +2 -2
- package/dist/packages/@ember/-internals/views/lib/views/states/in_dom.js +3 -1
- package/dist/packages/@ember/application/instance.js +1 -0
- package/dist/packages/@ember/application/lib/application.js +8 -1
- package/dist/packages/@ember/canary-features/index.js +2 -2
- package/dist/packages/@ember/engine/instance.js +1 -1
- package/dist/packages/@ember/engine/lib/engine-parent.js +1 -5
- package/dist/packages/@ember/renderer/index.js +28 -0
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +838 -712
- package/package.json +4 -3
|
@@ -3,34 +3,22 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Mixin, get } from '@ember/-internals/metal';
|
|
5
5
|
import { assert } from '@ember/debug';
|
|
6
|
-
/**
|
|
7
|
-
`Ember.ActionHandler` is available on some familiar classes including
|
|
8
|
-
`Route`, `Component`, and `Controller`.
|
|
9
|
-
(Internally the mixin is used by `Ember.CoreView`, `Ember.ControllerMixin`,
|
|
10
|
-
and `Route` and available to the above classes through
|
|
11
|
-
inheritance.)
|
|
12
|
-
|
|
13
|
-
@class ActionHandler
|
|
14
|
-
@namespace Ember
|
|
15
|
-
@private
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
6
|
const ActionHandler = Mixin.create({
|
|
19
7
|
mergedProperties: ['actions'],
|
|
20
8
|
|
|
21
9
|
/**
|
|
22
10
|
The collection of functions, keyed by name, available on this
|
|
23
11
|
`ActionHandler` as action targets.
|
|
24
|
-
|
|
12
|
+
These functions will be invoked when a matching `{{action}}` is triggered
|
|
25
13
|
from within a template and the application's current route is this route.
|
|
26
|
-
|
|
14
|
+
Actions can also be invoked from other parts of your application
|
|
27
15
|
via `ActionHandler#send`.
|
|
28
|
-
|
|
16
|
+
The `actions` hash will inherit action handlers from
|
|
29
17
|
the `actions` hash defined on extended parent classes
|
|
30
18
|
or mixins rather than just replace the entire hash, e.g.:
|
|
31
|
-
|
|
19
|
+
```app/mixins/can-display-banner.js
|
|
32
20
|
import Mixin from '@ember/mixin';
|
|
33
|
-
|
|
21
|
+
export default Mixin.create({
|
|
34
22
|
actions: {
|
|
35
23
|
displayBanner(msg) {
|
|
36
24
|
// ...
|
|
@@ -38,28 +26,28 @@ const ActionHandler = Mixin.create({
|
|
|
38
26
|
}
|
|
39
27
|
});
|
|
40
28
|
```
|
|
41
|
-
|
|
29
|
+
```app/routes/welcome.js
|
|
42
30
|
import Route from '@ember/routing/route';
|
|
43
31
|
import CanDisplayBanner from '../mixins/can-display-banner';
|
|
44
|
-
|
|
32
|
+
export default Route.extend(CanDisplayBanner, {
|
|
45
33
|
actions: {
|
|
46
34
|
playMusic() {
|
|
47
35
|
// ...
|
|
48
36
|
}
|
|
49
37
|
}
|
|
50
38
|
});
|
|
51
|
-
|
|
39
|
+
// `WelcomeRoute`, when active, will be able to respond
|
|
52
40
|
// to both actions, since the actions hash is merged rather
|
|
53
41
|
// then replaced when extending mixins / parent classes.
|
|
54
42
|
this.send('displayBanner');
|
|
55
43
|
this.send('playMusic');
|
|
56
44
|
```
|
|
57
|
-
|
|
45
|
+
Within a Controller, Route or Component's action handler,
|
|
58
46
|
the value of the `this` context is the Controller, Route or
|
|
59
47
|
Component object:
|
|
60
|
-
|
|
48
|
+
```app/routes/song.js
|
|
61
49
|
import Route from '@ember/routing/route';
|
|
62
|
-
|
|
50
|
+
export default Route.extend({
|
|
63
51
|
actions: {
|
|
64
52
|
myAction() {
|
|
65
53
|
this.controllerFor("song");
|
|
@@ -69,13 +57,13 @@ const ActionHandler = Mixin.create({
|
|
|
69
57
|
}
|
|
70
58
|
});
|
|
71
59
|
```
|
|
72
|
-
|
|
60
|
+
It is also possible to call `this._super(...arguments)` from within an
|
|
73
61
|
action handler if it overrides a handler defined on a parent
|
|
74
62
|
class or mixin:
|
|
75
|
-
|
|
76
|
-
|
|
63
|
+
Take for example the following routes:
|
|
64
|
+
```app/mixins/debug-route.js
|
|
77
65
|
import Mixin from '@ember/mixin';
|
|
78
|
-
|
|
66
|
+
export default Mixin.create({
|
|
79
67
|
actions: {
|
|
80
68
|
debugRouteInformation() {
|
|
81
69
|
console.debug("It's a-me, console.debug!");
|
|
@@ -83,54 +71,54 @@ const ActionHandler = Mixin.create({
|
|
|
83
71
|
}
|
|
84
72
|
});
|
|
85
73
|
```
|
|
86
|
-
|
|
74
|
+
```app/routes/annoying-debug.js
|
|
87
75
|
import Route from '@ember/routing/route';
|
|
88
76
|
import DebugRoute from '../mixins/debug-route';
|
|
89
|
-
|
|
77
|
+
export default Route.extend(DebugRoute, {
|
|
90
78
|
actions: {
|
|
91
79
|
debugRouteInformation() {
|
|
92
80
|
// also call the debugRouteInformation of mixed in DebugRoute
|
|
93
81
|
this._super(...arguments);
|
|
94
|
-
|
|
82
|
+
// show additional annoyance
|
|
95
83
|
window.alert(...);
|
|
96
84
|
}
|
|
97
85
|
}
|
|
98
86
|
});
|
|
99
87
|
```
|
|
100
|
-
|
|
101
|
-
|
|
88
|
+
## Bubbling
|
|
89
|
+
By default, an action will stop bubbling once a handler defined
|
|
102
90
|
on the `actions` hash handles it. To continue bubbling the action,
|
|
103
91
|
you must return `true` from the handler:
|
|
104
|
-
|
|
92
|
+
```app/router.js
|
|
105
93
|
Router.map(function() {
|
|
106
94
|
this.route("album", function() {
|
|
107
95
|
this.route("song");
|
|
108
96
|
});
|
|
109
97
|
});
|
|
110
98
|
```
|
|
111
|
-
|
|
99
|
+
```app/routes/album.js
|
|
112
100
|
import Route from '@ember/routing/route';
|
|
113
|
-
|
|
101
|
+
export default Route.extend({
|
|
114
102
|
actions: {
|
|
115
103
|
startPlaying: function() {
|
|
116
104
|
}
|
|
117
105
|
}
|
|
118
106
|
});
|
|
119
107
|
```
|
|
120
|
-
|
|
108
|
+
```app/routes/album-song.js
|
|
121
109
|
import Route from '@ember/routing/route';
|
|
122
|
-
|
|
110
|
+
export default Route.extend({
|
|
123
111
|
actions: {
|
|
124
112
|
startPlaying() {
|
|
125
113
|
// ...
|
|
126
|
-
|
|
114
|
+
if (actionShouldAlsoBeTriggeredOnParentRoute) {
|
|
127
115
|
return true;
|
|
128
116
|
}
|
|
129
117
|
}
|
|
130
118
|
}
|
|
131
119
|
});
|
|
132
120
|
```
|
|
133
|
-
|
|
121
|
+
@property actions
|
|
134
122
|
@type Object
|
|
135
123
|
@default null
|
|
136
124
|
@public
|
|
@@ -140,14 +128,14 @@ const ActionHandler = Mixin.create({
|
|
|
140
128
|
Triggers a named action on the `ActionHandler`. Any parameters
|
|
141
129
|
supplied after the `actionName` string will be passed as arguments
|
|
142
130
|
to the action target function.
|
|
143
|
-
|
|
131
|
+
If the `ActionHandler` has its `target` property set, actions may
|
|
144
132
|
bubble to the `target`. Bubbling happens when an `actionName` can
|
|
145
133
|
not be found in the `ActionHandler`'s `actions` hash or if the
|
|
146
134
|
action target function returns `true`.
|
|
147
|
-
|
|
148
|
-
|
|
135
|
+
Example
|
|
136
|
+
```app/routes/welcome.js
|
|
149
137
|
import Route from '@ember/routing/route';
|
|
150
|
-
|
|
138
|
+
export default Route.extend({
|
|
151
139
|
actions: {
|
|
152
140
|
playTheme() {
|
|
153
141
|
this.send('playMusic', 'theme.mp3');
|
|
@@ -158,7 +146,7 @@ const ActionHandler = Mixin.create({
|
|
|
158
146
|
}
|
|
159
147
|
});
|
|
160
148
|
```
|
|
161
|
-
|
|
149
|
+
@method send
|
|
162
150
|
@param {String} actionName The action to trigger
|
|
163
151
|
@param {*} context a context to send with the action
|
|
164
152
|
@public
|
|
@@ -1176,7 +1176,7 @@ const MutableArray = Mixin.create(ArrayMixin, MutableEnumerable, {
|
|
|
1176
1176
|
idx >= length, then append to the end of the array.
|
|
1177
1177
|
@param {Number} amt Number of elements that should be removed from
|
|
1178
1178
|
the array, starting at *idx*.
|
|
1179
|
-
@param {EmberArray} objects An array of zero or more objects that should be
|
|
1179
|
+
@param {EmberArray} [objects] An optional array of zero or more objects that should be
|
|
1180
1180
|
inserted into the array at *idx*
|
|
1181
1181
|
@public
|
|
1182
1182
|
*/
|
|
@@ -1,34 +1,19 @@
|
|
|
1
1
|
import { Mixin } from '@ember/-internals/metal';
|
|
2
|
-
|
|
3
|
-
@module ember
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
Implements some standard methods for comparing objects. Add this mixin to
|
|
8
|
-
any class you create that can compare its instances.
|
|
9
|
-
|
|
10
|
-
You should implement the `compare()` method.
|
|
11
|
-
|
|
12
|
-
@class Comparable
|
|
13
|
-
@namespace Ember
|
|
14
|
-
@since Ember 0.9
|
|
15
|
-
@private
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
export default Mixin.create({
|
|
2
|
+
const Comparable = Mixin.create({
|
|
19
3
|
/**
|
|
20
4
|
__Required.__ You must implement this method to apply this mixin.
|
|
21
|
-
|
|
5
|
+
Override to return the result of the comparison of the two parameters. The
|
|
22
6
|
compare method should return:
|
|
23
|
-
|
|
7
|
+
- `-1` if `a < b`
|
|
24
8
|
- `0` if `a == b`
|
|
25
9
|
- `1` if `a > b`
|
|
26
|
-
|
|
27
|
-
|
|
10
|
+
Default implementation raises an exception.
|
|
11
|
+
@method compare
|
|
28
12
|
@param a {Object} the first object to compare
|
|
29
13
|
@param b {Object} the second object to compare
|
|
30
14
|
@return {Number} the result of the comparison
|
|
31
15
|
@private
|
|
32
16
|
*/
|
|
33
17
|
compare: null
|
|
34
|
-
});
|
|
18
|
+
});
|
|
19
|
+
export default Comparable;
|
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
import { schedule, join } from '@ember/runloop';
|
|
2
|
-
/**
|
|
3
|
-
@module ember
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
2
|
import { Mixin } from '@ember/-internals/metal';
|
|
7
|
-
|
|
8
|
-
ContainerProxyMixin is used to provide public access to specific
|
|
9
|
-
container functionality.
|
|
10
|
-
|
|
11
|
-
@class ContainerProxyMixin
|
|
12
|
-
@private
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
let containerProxyMixin = {
|
|
3
|
+
const ContainerProxyMixin = Mixin.create({
|
|
16
4
|
/**
|
|
17
5
|
The container stores state.
|
|
18
|
-
|
|
6
|
+
@private
|
|
19
7
|
@property {Ember.Container} __container__
|
|
20
8
|
*/
|
|
21
9
|
__container__: null,
|
|
@@ -23,16 +11,16 @@ let containerProxyMixin = {
|
|
|
23
11
|
/**
|
|
24
12
|
Returns an object that can be used to provide an owner to a
|
|
25
13
|
manually created instance.
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
Example:
|
|
15
|
+
```
|
|
28
16
|
import { getOwner } from '@ember/application';
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
let owner = getOwner(this);
|
|
18
|
+
User.create(
|
|
31
19
|
owner.ownerInjection(),
|
|
32
20
|
{ username: 'rwjblue' }
|
|
33
21
|
)
|
|
34
22
|
```
|
|
35
|
-
|
|
23
|
+
@public
|
|
36
24
|
@method ownerInjection
|
|
37
25
|
@since 2.3.0
|
|
38
26
|
@return {Object}
|
|
@@ -43,30 +31,30 @@ let containerProxyMixin = {
|
|
|
43
31
|
|
|
44
32
|
/**
|
|
45
33
|
Given a fullName return a corresponding instance.
|
|
46
|
-
|
|
34
|
+
The default behavior is for lookup to return a singleton instance.
|
|
47
35
|
The singleton is scoped to the container, allowing multiple containers
|
|
48
36
|
to all have their own locally scoped singletons.
|
|
49
|
-
|
|
37
|
+
```javascript
|
|
50
38
|
let registry = new Registry();
|
|
51
39
|
let container = registry.container();
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
40
|
+
registry.register('api:twitter', Twitter);
|
|
41
|
+
let twitter = container.lookup('api:twitter');
|
|
42
|
+
twitter instanceof Twitter; // => true
|
|
43
|
+
// by default the container will return singletons
|
|
56
44
|
let twitter2 = container.lookup('api:twitter');
|
|
57
45
|
twitter2 instanceof Twitter; // => true
|
|
58
|
-
|
|
46
|
+
twitter === twitter2; //=> true
|
|
59
47
|
```
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
If singletons are not wanted an optional flag can be provided at lookup.
|
|
49
|
+
```javascript
|
|
62
50
|
let registry = new Registry();
|
|
63
51
|
let container = registry.container();
|
|
64
|
-
|
|
65
|
-
|
|
52
|
+
registry.register('api:twitter', Twitter);
|
|
53
|
+
let twitter = container.lookup('api:twitter', { singleton: false });
|
|
66
54
|
let twitter2 = container.lookup('api:twitter', { singleton: false });
|
|
67
|
-
|
|
55
|
+
twitter === twitter2; //=> false
|
|
68
56
|
```
|
|
69
|
-
|
|
57
|
+
@public
|
|
70
58
|
@method lookup
|
|
71
59
|
@param {String} fullName
|
|
72
60
|
@param {Object} options
|
|
@@ -91,40 +79,40 @@ let containerProxyMixin = {
|
|
|
91
79
|
|
|
92
80
|
/**
|
|
93
81
|
Given a fullName return a factory manager.
|
|
94
|
-
|
|
82
|
+
This method returns a manager which can be used for introspection of the
|
|
95
83
|
factory's class or for the creation of factory instances with initial
|
|
96
84
|
properties. The manager is an object with the following properties:
|
|
97
|
-
|
|
85
|
+
* `class` - The registered or resolved class.
|
|
98
86
|
* `create` - A function that will create an instance of the class with
|
|
99
87
|
any dependencies injected.
|
|
100
|
-
|
|
101
|
-
|
|
88
|
+
For example:
|
|
89
|
+
```javascript
|
|
102
90
|
import { getOwner } from '@ember/application';
|
|
103
|
-
|
|
91
|
+
let owner = getOwner(otherInstance);
|
|
104
92
|
// the owner is commonly the `applicationInstance`, and can be accessed via
|
|
105
93
|
// an instance initializer.
|
|
106
|
-
|
|
107
|
-
|
|
94
|
+
let factory = owner.factoryFor('service:bespoke');
|
|
95
|
+
factory.class;
|
|
108
96
|
// The registered or resolved class. For example when used with an Ember-CLI
|
|
109
97
|
// app, this would be the default export from `app/services/bespoke.js`.
|
|
110
|
-
|
|
98
|
+
let instance = factory.create({
|
|
111
99
|
someProperty: 'an initial property value'
|
|
112
100
|
});
|
|
113
101
|
// Create an instance with any injections and the passed options as
|
|
114
102
|
// initial properties.
|
|
115
103
|
```
|
|
116
|
-
|
|
104
|
+
Any instances created via the factory's `.create()` method *must* be destroyed
|
|
117
105
|
manually by the caller of `.create()`. Typically, this is done during the creating
|
|
118
106
|
objects own `destroy` or `willDestroy` methods.
|
|
119
|
-
|
|
107
|
+
@public
|
|
120
108
|
@method factoryFor
|
|
121
109
|
@param {String} fullName
|
|
122
110
|
@param {Object} options
|
|
123
111
|
@return {FactoryManager}
|
|
124
112
|
*/
|
|
125
|
-
factoryFor(fullName
|
|
126
|
-
return this.__container__.factoryFor(fullName
|
|
113
|
+
factoryFor(fullName) {
|
|
114
|
+
return this.__container__.factoryFor(fullName);
|
|
127
115
|
}
|
|
128
116
|
|
|
129
|
-
};
|
|
130
|
-
export default
|
|
117
|
+
});
|
|
118
|
+
export default ContainerProxyMixin;
|
|
@@ -1,16 +1,3 @@
|
|
|
1
1
|
import { Mixin } from '@ember/-internals/metal';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
@private
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
The methods in this mixin have been moved to [MutableArray](/ember/release/classes/MutableArray). This mixin has
|
|
9
|
-
been intentionally preserved to avoid breaking Enumerable.detect checks
|
|
10
|
-
until the community migrates away from them.
|
|
11
|
-
|
|
12
|
-
@class Enumerable
|
|
13
|
-
@private
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
export default Mixin.create();
|
|
2
|
+
const Enumerable = Mixin.create();
|
|
3
|
+
export default Enumerable;
|
|
@@ -1,62 +1,17 @@
|
|
|
1
1
|
import { Mixin, addListener, removeListener, hasListeners, sendEvent } from '@ember/-internals/metal';
|
|
2
|
-
|
|
3
|
-
@module @ember/object
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
This mixin allows for Ember objects to subscribe to and emit events.
|
|
8
|
-
|
|
9
|
-
```app/utils/person.js
|
|
10
|
-
import EmberObject from '@ember/object';
|
|
11
|
-
import Evented from '@ember/object/evented';
|
|
12
|
-
|
|
13
|
-
export default EmberObject.extend(Evented, {
|
|
14
|
-
greet() {
|
|
15
|
-
// ...
|
|
16
|
-
this.trigger('greet');
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
```javascript
|
|
22
|
-
var person = Person.create();
|
|
23
|
-
|
|
24
|
-
person.on('greet', function() {
|
|
25
|
-
console.log('Our person has greeted');
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
person.greet();
|
|
29
|
-
|
|
30
|
-
// outputs: 'Our person has greeted'
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
You can also chain multiple event subscriptions:
|
|
34
|
-
|
|
35
|
-
```javascript
|
|
36
|
-
person.on('greet', function() {
|
|
37
|
-
console.log('Our person has greeted');
|
|
38
|
-
}).one('greet', function() {
|
|
39
|
-
console.log('Offer one-time special');
|
|
40
|
-
}).off('event', this, forgetThis);
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
@class Evented
|
|
44
|
-
@public
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
export default Mixin.create({
|
|
2
|
+
const Evented = Mixin.create({
|
|
48
3
|
/**
|
|
49
4
|
Subscribes to a named event with given function.
|
|
50
|
-
|
|
5
|
+
```javascript
|
|
51
6
|
person.on('didLoad', function() {
|
|
52
7
|
// fired once the person has loaded
|
|
53
8
|
});
|
|
54
9
|
```
|
|
55
|
-
|
|
10
|
+
An optional target can be passed in as the 2nd argument that will
|
|
56
11
|
be set as the "this" for the callback. This is a good way to give your
|
|
57
12
|
function access to the object triggering the event. When the target
|
|
58
13
|
parameter is used the callback method becomes the third argument.
|
|
59
|
-
|
|
14
|
+
@method on
|
|
60
15
|
@param {String} name The name of the event
|
|
61
16
|
@param {Object} [target] The "this" binding for the callback
|
|
62
17
|
@param {Function|String} method A function or the name of a function to be called on `target`
|
|
@@ -72,10 +27,10 @@ export default Mixin.create({
|
|
|
72
27
|
Subscribes a function to a named event and then cancels the subscription
|
|
73
28
|
after the first time the event is triggered. It is good to use ``one`` when
|
|
74
29
|
you only care about the first time an event has taken place.
|
|
75
|
-
|
|
30
|
+
This function takes an optional 2nd argument that will become the "this"
|
|
76
31
|
value for the callback. When the target parameter is used the callback method
|
|
77
32
|
becomes the third argument.
|
|
78
|
-
|
|
33
|
+
@method one
|
|
79
34
|
@param {String} name The name of the event
|
|
80
35
|
@param {Object} [target] The "this" binding for the callback
|
|
81
36
|
@param {Function|String} method A function or the name of a function to be called on `target`
|
|
@@ -91,12 +46,12 @@ export default Mixin.create({
|
|
|
91
46
|
Triggers a named event for the object. Any additional arguments
|
|
92
47
|
will be passed as parameters to the functions that are subscribed to the
|
|
93
48
|
event.
|
|
94
|
-
|
|
49
|
+
```javascript
|
|
95
50
|
person.on('didEat', function(food) {
|
|
96
51
|
console.log('person ate some ' + food);
|
|
97
52
|
});
|
|
98
|
-
|
|
99
|
-
|
|
53
|
+
person.trigger('didEat', 'broccoli');
|
|
54
|
+
// outputs: person ate some broccoli
|
|
100
55
|
```
|
|
101
56
|
@method trigger
|
|
102
57
|
@param {String} name The name of the event
|
|
@@ -109,7 +64,7 @@ export default Mixin.create({
|
|
|
109
64
|
|
|
110
65
|
/**
|
|
111
66
|
Cancels subscription for given name, target, and method.
|
|
112
|
-
|
|
67
|
+
@method off
|
|
113
68
|
@param {String} name The name of the event
|
|
114
69
|
@param {Object} target The target of the subscription
|
|
115
70
|
@param {Function|String} method The function or the name of a function of the subscription
|
|
@@ -123,7 +78,7 @@ export default Mixin.create({
|
|
|
123
78
|
|
|
124
79
|
/**
|
|
125
80
|
Checks to see if object has any subscriptions for named event.
|
|
126
|
-
|
|
81
|
+
@method has
|
|
127
82
|
@param {String} name The name of the event
|
|
128
83
|
@return {Boolean} does the object have a subscription for event
|
|
129
84
|
@public
|
|
@@ -132,4 +87,5 @@ export default Mixin.create({
|
|
|
132
87
|
return hasListeners(this, name);
|
|
133
88
|
}
|
|
134
89
|
|
|
135
|
-
});
|
|
90
|
+
});
|
|
91
|
+
export default Evented;
|
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
import Enumerable from './enumerable';
|
|
2
2
|
import { Mixin } from '@ember/-internals/metal';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
The methods in this mixin have been moved to MutableArray. This mixin has
|
|
9
|
-
been intentionally preserved to avoid breaking MutableEnumerable.detect
|
|
10
|
-
checks until the community migrates away from them.
|
|
11
|
-
|
|
12
|
-
@class MutableEnumerable
|
|
13
|
-
@namespace Ember
|
|
14
|
-
@uses Enumerable
|
|
15
|
-
@private
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
export default Mixin.create(Enumerable);
|
|
3
|
+
const MutableEnumerable = Mixin.create(Enumerable);
|
|
4
|
+
export default MutableEnumerable;
|