ember-source 4.9.0-alpha.3 → 4.9.0-alpha.4
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 +4 -0
- package/build-metadata.json +3 -3
- package/dist/ember-template-compiler.js +9 -4
- 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 +28 -1427
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/glimmer/index.js +5 -5
- package/dist/packages/@ember/-internals/meta/lib/meta.js +13 -13
- package/dist/packages/@ember/array/index.js +0 -909
- package/dist/packages/@ember/array/proxy.js +0 -31
- package/dist/packages/@ember/controller/index.js +0 -156
- package/dist/packages/@ember/debug/data-adapter.js +8 -2
- package/dist/packages/@ember/object/observable.js +0 -228
- package/dist/packages/@ember/object/promise-proxy-mixin.js +0 -80
- package/dist/packages/@ember/routing/route.js +1 -1
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +262 -383
- package/package.json +10 -9
|
@@ -92,17 +92,6 @@ class ArrayProxy extends EmberObject {
|
|
|
92
92
|
willDestroy() {
|
|
93
93
|
this._removeArrangedContentArrayObserver();
|
|
94
94
|
}
|
|
95
|
-
/**
|
|
96
|
-
Should actually retrieve the object at the specified index from the
|
|
97
|
-
content. You can override this method in subclasses to transform the
|
|
98
|
-
content item to something new.
|
|
99
|
-
This method will only be called if content is non-`null`.
|
|
100
|
-
@method objectAtContent
|
|
101
|
-
@param {Number} idx The index to retrieve.
|
|
102
|
-
@return {Object} the value or undefined if none found
|
|
103
|
-
@public
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
95
|
|
|
107
96
|
objectAtContent(idx) {
|
|
108
97
|
let arrangedContent = get(this, 'arrangedContent');
|
|
@@ -116,19 +105,6 @@ class ArrayProxy extends EmberObject {
|
|
|
116
105
|
assert('Mutating an arranged ArrayProxy is not allowed', get(this, 'arrangedContent') === get(this, 'content'));
|
|
117
106
|
this.replaceContent(idx, amt, objects);
|
|
118
107
|
}
|
|
119
|
-
/**
|
|
120
|
-
Should actually replace the specified objects on the content array.
|
|
121
|
-
You can override this method in subclasses to transform the content item
|
|
122
|
-
into something new.
|
|
123
|
-
This method will only be called if content is non-`null`.
|
|
124
|
-
@method replaceContent
|
|
125
|
-
@param {Number} idx The starting index
|
|
126
|
-
@param {Number} amt The number of items to remove from the content.
|
|
127
|
-
@param {Array} objects Optional array of objects to insert.
|
|
128
|
-
@return {void}
|
|
129
|
-
@public
|
|
130
|
-
*/
|
|
131
|
-
|
|
132
108
|
|
|
133
109
|
replaceContent(idx, amt, objects) {
|
|
134
110
|
let content = get(this, 'content');
|
|
@@ -295,13 +271,6 @@ class ArrayProxy extends EmberObject {
|
|
|
295
271
|
}
|
|
296
272
|
|
|
297
273
|
ArrayProxy.reopen(MutableArray, {
|
|
298
|
-
/**
|
|
299
|
-
The array that the proxy pretends to be. In the default `ArrayProxy`
|
|
300
|
-
implementation, this and `content` are the same. Subclasses of `ArrayProxy`
|
|
301
|
-
can override this property to provide things like sorting and filtering.
|
|
302
|
-
@property arrangedContent
|
|
303
|
-
@public
|
|
304
|
-
*/
|
|
305
274
|
arrangedContent: alias('content')
|
|
306
275
|
});
|
|
307
276
|
export default ArrayProxy;
|
|
@@ -12,20 +12,6 @@ const ControllerMixin = Mixin.create(ActionHandler, {
|
|
|
12
12
|
/* ducktype as a controller */
|
|
13
13
|
isController: true,
|
|
14
14
|
concatenatedProperties: ['queryParams'],
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
The object to which actions from the view should be sent.
|
|
18
|
-
For example, when a Handlebars template uses the `{{action}}` helper,
|
|
19
|
-
it will attempt to send the action to the view's controller's `target`.
|
|
20
|
-
By default, the value of the target property is set to the router, and
|
|
21
|
-
is injected when a controller is instantiated. This injection is applied
|
|
22
|
-
as part of the application's initialization process. In most cases the
|
|
23
|
-
`target` property will automatically be set to the logical consumer of
|
|
24
|
-
actions for the controller.
|
|
25
|
-
@property target
|
|
26
|
-
@default null
|
|
27
|
-
@public
|
|
28
|
-
*/
|
|
29
15
|
target: null,
|
|
30
16
|
store: null,
|
|
31
17
|
|
|
@@ -40,12 +26,6 @@ const ControllerMixin = Mixin.create(ActionHandler, {
|
|
|
40
26
|
}
|
|
41
27
|
},
|
|
42
28
|
|
|
43
|
-
/**
|
|
44
|
-
The controller's current model. When retrieving or modifying a controller's
|
|
45
|
-
model, this property should be used instead of the `content` property.
|
|
46
|
-
@property model
|
|
47
|
-
@public
|
|
48
|
-
*/
|
|
49
29
|
model: computed({
|
|
50
30
|
get() {
|
|
51
31
|
return this[MODEL];
|
|
@@ -56,30 +36,6 @@ const ControllerMixin = Mixin.create(ActionHandler, {
|
|
|
56
36
|
}
|
|
57
37
|
|
|
58
38
|
}),
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
Defines which query parameters the controller accepts.
|
|
62
|
-
If you give the names `['category','page']` it will bind
|
|
63
|
-
the values of these query parameters to the variables
|
|
64
|
-
`this.category` and `this.page`.
|
|
65
|
-
By default, query parameters are parsed as strings. This
|
|
66
|
-
may cause unexpected behavior if a query parameter is used with `toggleProperty`,
|
|
67
|
-
because the initial value set for `param=false` will be the string `"false"`, which is truthy.
|
|
68
|
-
To avoid this, you may specify that the query parameter should be parsed as a boolean
|
|
69
|
-
by using the following verbose form with a `type` property:
|
|
70
|
-
```javascript
|
|
71
|
-
queryParams: [{
|
|
72
|
-
category: {
|
|
73
|
-
type: 'boolean'
|
|
74
|
-
}
|
|
75
|
-
}]
|
|
76
|
-
```
|
|
77
|
-
Available values for the `type` parameter are `'boolean'`, `'number'`, `'array'`, and `'string'`.
|
|
78
|
-
If query param type is not specified, it will default to `'string'`.
|
|
79
|
-
@for Ember.ControllerMixin
|
|
80
|
-
@property queryParams
|
|
81
|
-
@public
|
|
82
|
-
*/
|
|
83
39
|
queryParams: null,
|
|
84
40
|
|
|
85
41
|
/**
|
|
@@ -119,67 +75,6 @@ const ControllerMixin = Mixin.create(ActionHandler, {
|
|
|
119
75
|
delegate(prop, value);
|
|
120
76
|
},
|
|
121
77
|
|
|
122
|
-
/**
|
|
123
|
-
Transition the application into another route. The route may
|
|
124
|
-
be either a single route or route path:
|
|
125
|
-
```javascript
|
|
126
|
-
aController.transitionToRoute('blogPosts');
|
|
127
|
-
aController.transitionToRoute('blogPosts.recentEntries');
|
|
128
|
-
```
|
|
129
|
-
Optionally supply a model for the route in question. The model
|
|
130
|
-
will be serialized into the URL using the `serialize` hook of
|
|
131
|
-
the route:
|
|
132
|
-
```javascript
|
|
133
|
-
aController.transitionToRoute('blogPost', aPost);
|
|
134
|
-
```
|
|
135
|
-
If a literal is passed (such as a number or a string), it will
|
|
136
|
-
be treated as an identifier instead. In this case, the `model`
|
|
137
|
-
hook of the route will be triggered:
|
|
138
|
-
```javascript
|
|
139
|
-
aController.transitionToRoute('blogPost', 1);
|
|
140
|
-
```
|
|
141
|
-
Multiple models will be applied last to first recursively up the
|
|
142
|
-
route tree.
|
|
143
|
-
```app/router.js
|
|
144
|
-
Router.map(function() {
|
|
145
|
-
this.route('blogPost', { path: ':blogPostId' }, function() {
|
|
146
|
-
this.route('blogComment', { path: ':blogCommentId', resetNamespace: true });
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
```
|
|
150
|
-
```javascript
|
|
151
|
-
aController.transitionToRoute('blogComment', aPost, aComment);
|
|
152
|
-
aController.transitionToRoute('blogComment', 1, 13);
|
|
153
|
-
```
|
|
154
|
-
It is also possible to pass a URL (a string that starts with a
|
|
155
|
-
`/`).
|
|
156
|
-
```javascript
|
|
157
|
-
aController.transitionToRoute('/');
|
|
158
|
-
aController.transitionToRoute('/blog/post/1/comment/13');
|
|
159
|
-
aController.transitionToRoute('/blog/posts?sort=title');
|
|
160
|
-
```
|
|
161
|
-
An options hash with a `queryParams` property may be provided as
|
|
162
|
-
the final argument to add query parameters to the destination URL.
|
|
163
|
-
```javascript
|
|
164
|
-
aController.transitionToRoute('blogPost', 1, {
|
|
165
|
-
queryParams: { showComments: 'true' }
|
|
166
|
-
});
|
|
167
|
-
// if you just want to transition the query parameters without changing the route
|
|
168
|
-
aController.transitionToRoute({ queryParams: { sort: 'date' } });
|
|
169
|
-
```
|
|
170
|
-
See also [replaceRoute](/ember/release/classes/Ember.ControllerMixin/methods/replaceRoute?anchor=replaceRoute).
|
|
171
|
-
@for Ember.ControllerMixin
|
|
172
|
-
@method transitionToRoute
|
|
173
|
-
@deprecated Use transitionTo from the Router service instead.
|
|
174
|
-
@param {String} [name] the name of the route or a URL
|
|
175
|
-
@param {...Object} models the model(s) or identifier(s) to be used
|
|
176
|
-
while transitioning to the route.
|
|
177
|
-
@param {Object} [options] optional hash with a queryParams property
|
|
178
|
-
containing a mapping of query parameters
|
|
179
|
-
@return {Transition} the transition object associated with this
|
|
180
|
-
attempted transition
|
|
181
|
-
@public
|
|
182
|
-
*/
|
|
183
78
|
transitionToRoute(...args) {
|
|
184
79
|
var _a;
|
|
185
80
|
|
|
@@ -193,57 +88,6 @@ const ControllerMixin = Mixin.create(ActionHandler, {
|
|
|
193
88
|
return method.apply(target, prefixRouteNameArg(this, args));
|
|
194
89
|
},
|
|
195
90
|
|
|
196
|
-
/**
|
|
197
|
-
Transition into another route while replacing the current URL, if possible.
|
|
198
|
-
This will replace the current history entry instead of adding a new one.
|
|
199
|
-
Beside that, it is identical to `transitionToRoute` in all other respects.
|
|
200
|
-
```javascript
|
|
201
|
-
aController.replaceRoute('blogPosts');
|
|
202
|
-
aController.replaceRoute('blogPosts.recentEntries');
|
|
203
|
-
```
|
|
204
|
-
Optionally supply a model for the route in question. The model
|
|
205
|
-
will be serialized into the URL using the `serialize` hook of
|
|
206
|
-
the route:
|
|
207
|
-
```javascript
|
|
208
|
-
aController.replaceRoute('blogPost', aPost);
|
|
209
|
-
```
|
|
210
|
-
If a literal is passed (such as a number or a string), it will
|
|
211
|
-
be treated as an identifier instead. In this case, the `model`
|
|
212
|
-
hook of the route will be triggered:
|
|
213
|
-
```javascript
|
|
214
|
-
aController.replaceRoute('blogPost', 1);
|
|
215
|
-
```
|
|
216
|
-
Multiple models will be applied last to first recursively up the
|
|
217
|
-
route tree.
|
|
218
|
-
```app/router.js
|
|
219
|
-
Router.map(function() {
|
|
220
|
-
this.route('blogPost', { path: ':blogPostId' }, function() {
|
|
221
|
-
this.route('blogComment', { path: ':blogCommentId', resetNamespace: true });
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
```
|
|
225
|
-
```
|
|
226
|
-
aController.replaceRoute('blogComment', aPost, aComment);
|
|
227
|
-
aController.replaceRoute('blogComment', 1, 13);
|
|
228
|
-
```
|
|
229
|
-
It is also possible to pass a URL (a string that starts with a
|
|
230
|
-
`/`).
|
|
231
|
-
```javascript
|
|
232
|
-
aController.replaceRoute('/');
|
|
233
|
-
aController.replaceRoute('/blog/post/1/comment/13');
|
|
234
|
-
```
|
|
235
|
-
@for Ember.ControllerMixin
|
|
236
|
-
@method replaceRoute
|
|
237
|
-
@deprecated Use replaceWith from the Router service instead.
|
|
238
|
-
@param {String} [name] the name of the route or a URL
|
|
239
|
-
@param {...Object} models the model(s) or identifier(s) to be used
|
|
240
|
-
while transitioning to the route.
|
|
241
|
-
@param {Object} [options] optional hash with a queryParams property
|
|
242
|
-
containing a mapping of query parameters
|
|
243
|
-
@return {Transition} the transition object associated with this
|
|
244
|
-
attempted transition
|
|
245
|
-
@public
|
|
246
|
-
*/
|
|
247
91
|
replaceRoute(...args) {
|
|
248
92
|
var _a;
|
|
249
93
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { getOwner } from '@ember/-internals/owner';
|
|
2
|
-
import { _backburner } from '@ember/runloop';
|
|
2
|
+
import { _backburner, next } from '@ember/runloop';
|
|
3
3
|
import { get } from '@ember/object';
|
|
4
4
|
import { dasherize } from '@ember/string';
|
|
5
5
|
import Namespace from '@ember/application/namespace';
|
|
6
6
|
import EmberObject from '@ember/object';
|
|
7
7
|
import { A as emberA } from '@ember/array';
|
|
8
8
|
import { consumeTag, createCache, getValue, tagFor, untrack } from '@glimmer/validator';
|
|
9
|
+
import { assert } from '.';
|
|
9
10
|
|
|
10
11
|
function iterate(arr, fn) {
|
|
11
12
|
if (Symbol.iterator in arr) {
|
|
@@ -13,6 +14,11 @@ function iterate(arr, fn) {
|
|
|
13
14
|
fn(item);
|
|
14
15
|
}
|
|
15
16
|
} else {
|
|
17
|
+
// SAFETY: this cast required to work this way to interop between TS 4.8
|
|
18
|
+
// and 4.9. When we drop support for 4.8, it will narrow correctly via the
|
|
19
|
+
// use of the `in` operator above. (Preferably we will solve this by just
|
|
20
|
+
// switching to require `Symbol.iterator` instead.)
|
|
21
|
+
assert('', typeof arr.forEach === 'function');
|
|
16
22
|
arr.forEach(fn);
|
|
17
23
|
}
|
|
18
24
|
}
|
|
@@ -98,7 +104,7 @@ class TypeWatcher {
|
|
|
98
104
|
consumeTag(tagFor(records, '[]'));
|
|
99
105
|
|
|
100
106
|
if (hasBeenAccessed === true) {
|
|
101
|
-
onChange
|
|
107
|
+
next(onChange);
|
|
102
108
|
} else {
|
|
103
109
|
hasBeenAccessed = true;
|
|
104
110
|
}
|
|
@@ -7,113 +7,18 @@ import { get, set, getProperties, setProperties } from '@ember/object';
|
|
|
7
7
|
import Mixin from '@ember/object/mixin';
|
|
8
8
|
import { assert } from '@ember/debug';
|
|
9
9
|
const Observable = Mixin.create({
|
|
10
|
-
/**
|
|
11
|
-
Retrieves the value of a property from the object.
|
|
12
|
-
This method is usually similar to using `object[keyName]` or `object.keyName`,
|
|
13
|
-
however it supports both computed properties and the unknownProperty
|
|
14
|
-
handler.
|
|
15
|
-
Because `get` unifies the syntax for accessing all these kinds
|
|
16
|
-
of properties, it can make many refactorings easier, such as replacing a
|
|
17
|
-
simple property with a computed property, or vice versa.
|
|
18
|
-
### Computed Properties
|
|
19
|
-
Computed properties are methods defined with the `property` modifier
|
|
20
|
-
declared at the end, such as:
|
|
21
|
-
```javascript
|
|
22
|
-
import { computed } from '@ember/object';
|
|
23
|
-
fullName: computed('firstName', 'lastName', function() {
|
|
24
|
-
return this.get('firstName') + ' ' + this.get('lastName');
|
|
25
|
-
})
|
|
26
|
-
```
|
|
27
|
-
When you call `get` on a computed property, the function will be
|
|
28
|
-
called and the return value will be returned instead of the function
|
|
29
|
-
itself.
|
|
30
|
-
### Unknown Properties
|
|
31
|
-
Likewise, if you try to call `get` on a property whose value is
|
|
32
|
-
`undefined`, the `unknownProperty()` method will be called on the object.
|
|
33
|
-
If this method returns any value other than `undefined`, it will be returned
|
|
34
|
-
instead. This allows you to implement "virtual" properties that are
|
|
35
|
-
not defined upfront.
|
|
36
|
-
@method get
|
|
37
|
-
@param {String} keyName The property to retrieve
|
|
38
|
-
@return {Object} The property value or undefined.
|
|
39
|
-
@public
|
|
40
|
-
*/
|
|
41
10
|
get(keyName) {
|
|
42
11
|
return get(this, keyName);
|
|
43
12
|
},
|
|
44
13
|
|
|
45
|
-
/**
|
|
46
|
-
To get the values of multiple properties at once, call `getProperties`
|
|
47
|
-
with a list of strings or an array:
|
|
48
|
-
```javascript
|
|
49
|
-
record.getProperties('firstName', 'lastName', 'zipCode');
|
|
50
|
-
// { firstName: 'John', lastName: 'Doe', zipCode: '10011' }
|
|
51
|
-
```
|
|
52
|
-
is equivalent to:
|
|
53
|
-
```javascript
|
|
54
|
-
record.getProperties(['firstName', 'lastName', 'zipCode']);
|
|
55
|
-
// { firstName: 'John', lastName: 'Doe', zipCode: '10011' }
|
|
56
|
-
```
|
|
57
|
-
@method getProperties
|
|
58
|
-
@param {String...|Array} list of keys to get
|
|
59
|
-
@return {Object}
|
|
60
|
-
@public
|
|
61
|
-
*/
|
|
62
14
|
getProperties(...args) {
|
|
63
15
|
return getProperties(this, ...args);
|
|
64
16
|
},
|
|
65
17
|
|
|
66
|
-
/**
|
|
67
|
-
Sets the provided key or path to the value.
|
|
68
|
-
```javascript
|
|
69
|
-
record.set("key", value);
|
|
70
|
-
```
|
|
71
|
-
This method is generally very similar to calling `object["key"] = value` or
|
|
72
|
-
`object.key = value`, except that it provides support for computed
|
|
73
|
-
properties, the `setUnknownProperty()` method and property observers.
|
|
74
|
-
### Computed Properties
|
|
75
|
-
If you try to set a value on a key that has a computed property handler
|
|
76
|
-
defined (see the `get()` method for an example), then `set()` will call
|
|
77
|
-
that method, passing both the value and key instead of simply changing
|
|
78
|
-
the value itself. This is useful for those times when you need to
|
|
79
|
-
implement a property that is composed of one or more member
|
|
80
|
-
properties.
|
|
81
|
-
### Unknown Properties
|
|
82
|
-
If you try to set a value on a key that is undefined in the target
|
|
83
|
-
object, then the `setUnknownProperty()` handler will be called instead. This
|
|
84
|
-
gives you an opportunity to implement complex "virtual" properties that
|
|
85
|
-
are not predefined on the object. If `setUnknownProperty()` returns
|
|
86
|
-
undefined, then `set()` will simply set the value on the object.
|
|
87
|
-
### Property Observers
|
|
88
|
-
In addition to changing the property, `set()` will also register a property
|
|
89
|
-
change with the object. Unless you have placed this call inside of a
|
|
90
|
-
`beginPropertyChanges()` and `endPropertyChanges(),` any "local" observers
|
|
91
|
-
(i.e. observer methods declared on the same object), will be called
|
|
92
|
-
immediately. Any "remote" observers (i.e. observer methods declared on
|
|
93
|
-
another object) will be placed in a queue and called at a later time in a
|
|
94
|
-
coalesced manner.
|
|
95
|
-
@method set
|
|
96
|
-
@param {String} keyName The property to set
|
|
97
|
-
@param {Object} value The value to set or `null`.
|
|
98
|
-
@return {Object} The passed value
|
|
99
|
-
@public
|
|
100
|
-
*/
|
|
101
18
|
set(keyName, value) {
|
|
102
19
|
return set(this, keyName, value);
|
|
103
20
|
},
|
|
104
21
|
|
|
105
|
-
/**
|
|
106
|
-
Sets a list of properties at once. These properties are set inside
|
|
107
|
-
a single `beginPropertyChanges` and `endPropertyChanges` batch, so
|
|
108
|
-
observers will be buffered.
|
|
109
|
-
```javascript
|
|
110
|
-
record.setProperties({ firstName: 'Charles', lastName: 'Jolley' });
|
|
111
|
-
```
|
|
112
|
-
@method setProperties
|
|
113
|
-
@param {Object} hash the hash of keys and values to set
|
|
114
|
-
@return {Object} The passed in hash
|
|
115
|
-
@public
|
|
116
|
-
*/
|
|
117
22
|
setProperties(hash) {
|
|
118
23
|
return setProperties(this, hash);
|
|
119
24
|
},
|
|
@@ -153,104 +58,16 @@ const Observable = Mixin.create({
|
|
|
153
58
|
return this;
|
|
154
59
|
},
|
|
155
60
|
|
|
156
|
-
/**
|
|
157
|
-
Notify the observer system that a property has just changed.
|
|
158
|
-
Sometimes you need to change a value directly or indirectly without
|
|
159
|
-
actually calling `get()` or `set()` on it. In this case, you can use this
|
|
160
|
-
method instead. Calling this method will notify all observers that the
|
|
161
|
-
property has potentially changed value.
|
|
162
|
-
@method notifyPropertyChange
|
|
163
|
-
@param {String} keyName The property key to be notified about.
|
|
164
|
-
@return {Observable}
|
|
165
|
-
@public
|
|
166
|
-
*/
|
|
167
61
|
notifyPropertyChange(keyName) {
|
|
168
62
|
notifyPropertyChange(this, keyName);
|
|
169
63
|
return this;
|
|
170
64
|
},
|
|
171
65
|
|
|
172
|
-
/**
|
|
173
|
-
Adds an observer on a property.
|
|
174
|
-
This is the core method used to register an observer for a property.
|
|
175
|
-
Once you call this method, any time the key's value is set, your observer
|
|
176
|
-
will be notified. Note that the observers are triggered any time the
|
|
177
|
-
value is set, regardless of whether it has actually changed. Your
|
|
178
|
-
observer should be prepared to handle that.
|
|
179
|
-
There are two common invocation patterns for `.addObserver()`:
|
|
180
|
-
- Passing two arguments:
|
|
181
|
-
- the name of the property to observe (as a string)
|
|
182
|
-
- the function to invoke (an actual function)
|
|
183
|
-
- Passing three arguments:
|
|
184
|
-
- the name of the property to observe (as a string)
|
|
185
|
-
- the target object (will be used to look up and invoke a
|
|
186
|
-
function on)
|
|
187
|
-
- the name of the function to invoke on the target object
|
|
188
|
-
(as a string).
|
|
189
|
-
```app/components/my-component.js
|
|
190
|
-
import Component from '@ember/component';
|
|
191
|
-
export default Component.extend({
|
|
192
|
-
init() {
|
|
193
|
-
this._super(...arguments);
|
|
194
|
-
// the following are equivalent:
|
|
195
|
-
// using three arguments
|
|
196
|
-
this.addObserver('foo', this, 'fooDidChange');
|
|
197
|
-
// using two arguments
|
|
198
|
-
this.addObserver('foo', (...args) => {
|
|
199
|
-
this.fooDidChange(...args);
|
|
200
|
-
});
|
|
201
|
-
},
|
|
202
|
-
fooDidChange() {
|
|
203
|
-
// your custom logic code
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
```
|
|
207
|
-
### Observer Methods
|
|
208
|
-
Observer methods have the following signature:
|
|
209
|
-
```app/components/my-component.js
|
|
210
|
-
import Component from '@ember/component';
|
|
211
|
-
export default Component.extend({
|
|
212
|
-
init() {
|
|
213
|
-
this._super(...arguments);
|
|
214
|
-
this.addObserver('foo', this, 'fooDidChange');
|
|
215
|
-
},
|
|
216
|
-
fooDidChange(sender, key, value, rev) {
|
|
217
|
-
// your code
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
```
|
|
221
|
-
The `sender` is the object that changed. The `key` is the property that
|
|
222
|
-
changes. The `value` property is currently reserved and unused. The `rev`
|
|
223
|
-
is the last property revision of the object when it changed, which you can
|
|
224
|
-
use to detect if the key value has really changed or not.
|
|
225
|
-
Usually you will not need the value or revision parameters at
|
|
226
|
-
the end. In this case, it is common to write observer methods that take
|
|
227
|
-
only a sender and key value as parameters or, if you aren't interested in
|
|
228
|
-
any of these values, to write an observer that has no parameters at all.
|
|
229
|
-
@method addObserver
|
|
230
|
-
@param {String} key The key to observe
|
|
231
|
-
@param {Object} target The target object to invoke
|
|
232
|
-
@param {String|Function} method The method to invoke
|
|
233
|
-
@param {Boolean} sync Whether the observer is sync or not
|
|
234
|
-
@return {Observable}
|
|
235
|
-
@public
|
|
236
|
-
*/
|
|
237
66
|
addObserver(key, target, method, sync) {
|
|
238
67
|
addObserver(this, key, target, method, sync);
|
|
239
68
|
return this;
|
|
240
69
|
},
|
|
241
70
|
|
|
242
|
-
/**
|
|
243
|
-
Remove an observer you have previously registered on this object. Pass
|
|
244
|
-
the same key, target, and method you passed to `addObserver()` and your
|
|
245
|
-
target will no longer receive notifications.
|
|
246
|
-
@method removeObserver
|
|
247
|
-
@param {String} key The key to observe
|
|
248
|
-
@param {Object} target The target object to invoke
|
|
249
|
-
@param {String|Function} method The method to invoke
|
|
250
|
-
@param {Boolean} sync Whether the observer is async or not
|
|
251
|
-
@return {Observable}
|
|
252
|
-
@public
|
|
253
|
-
*/
|
|
254
71
|
removeObserver(key, target, method, sync) {
|
|
255
72
|
removeObserver(this, key, target, method, sync);
|
|
256
73
|
return this;
|
|
@@ -270,65 +87,20 @@ const Observable = Mixin.create({
|
|
|
270
87
|
return hasListeners(this, `${key}:change`);
|
|
271
88
|
},
|
|
272
89
|
|
|
273
|
-
/**
|
|
274
|
-
Set the value of a property to the current value plus some amount.
|
|
275
|
-
```javascript
|
|
276
|
-
person.incrementProperty('age');
|
|
277
|
-
team.incrementProperty('score', 2);
|
|
278
|
-
```
|
|
279
|
-
@method incrementProperty
|
|
280
|
-
@param {String} keyName The name of the property to increment
|
|
281
|
-
@param {Number} increment The amount to increment by. Defaults to 1
|
|
282
|
-
@return {Number} The new property value
|
|
283
|
-
@public
|
|
284
|
-
*/
|
|
285
90
|
incrementProperty(keyName, increment = 1) {
|
|
286
91
|
assert('Must pass a numeric value to incrementProperty', !isNaN(parseFloat(String(increment))) && isFinite(increment));
|
|
287
92
|
return set(this, keyName, (parseFloat(get(this, keyName)) || 0) + increment);
|
|
288
93
|
},
|
|
289
94
|
|
|
290
|
-
/**
|
|
291
|
-
Set the value of a property to the current value minus some amount.
|
|
292
|
-
```javascript
|
|
293
|
-
player.decrementProperty('lives');
|
|
294
|
-
orc.decrementProperty('health', 5);
|
|
295
|
-
```
|
|
296
|
-
@method decrementProperty
|
|
297
|
-
@param {String} keyName The name of the property to decrement
|
|
298
|
-
@param {Number} decrement The amount to decrement by. Defaults to 1
|
|
299
|
-
@return {Number} The new property value
|
|
300
|
-
@public
|
|
301
|
-
*/
|
|
302
95
|
decrementProperty(keyName, decrement = 1) {
|
|
303
96
|
assert('Must pass a numeric value to decrementProperty', (typeof decrement === 'number' || !isNaN(parseFloat(decrement))) && isFinite(decrement));
|
|
304
97
|
return set(this, keyName, (get(this, keyName) || 0) - decrement);
|
|
305
98
|
},
|
|
306
99
|
|
|
307
|
-
/**
|
|
308
|
-
Set the value of a boolean property to the opposite of its
|
|
309
|
-
current value.
|
|
310
|
-
```javascript
|
|
311
|
-
starship.toggleProperty('warpDriveEngaged');
|
|
312
|
-
```
|
|
313
|
-
@method toggleProperty
|
|
314
|
-
@param {String} keyName The name of the property to toggle
|
|
315
|
-
@return {Boolean} The new property value
|
|
316
|
-
@public
|
|
317
|
-
*/
|
|
318
100
|
toggleProperty(keyName) {
|
|
319
101
|
return set(this, keyName, !get(this, keyName));
|
|
320
102
|
},
|
|
321
103
|
|
|
322
|
-
/**
|
|
323
|
-
Returns the cached value of a computed property, if it exists.
|
|
324
|
-
This allows you to inspect the value of a computed property
|
|
325
|
-
without accidentally invoking it if it is intended to be
|
|
326
|
-
generated lazily.
|
|
327
|
-
@method cacheFor
|
|
328
|
-
@param {String} keyName
|
|
329
|
-
@return {Object} The cached value of the computed property, if any
|
|
330
|
-
@public
|
|
331
|
-
*/
|
|
332
104
|
cacheFor(keyName) {
|
|
333
105
|
let meta = peekMeta(this);
|
|
334
106
|
|
|
@@ -32,66 +32,15 @@ function tap(proxy, promise) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const PromiseProxyMixin = Mixin.create({
|
|
35
|
-
/**
|
|
36
|
-
If the proxied promise is rejected this will contain the reason
|
|
37
|
-
provided.
|
|
38
|
-
@property reason
|
|
39
|
-
@default null
|
|
40
|
-
@public
|
|
41
|
-
*/
|
|
42
35
|
reason: null,
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
Once the proxied promise has settled this will become `false`.
|
|
46
|
-
@property isPending
|
|
47
|
-
@default true
|
|
48
|
-
@public
|
|
49
|
-
*/
|
|
50
36
|
isPending: computed('isSettled', function () {
|
|
51
37
|
return !get(this, 'isSettled');
|
|
52
38
|
}).readOnly(),
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
Once the proxied promise has settled this will become `true`.
|
|
56
|
-
@property isSettled
|
|
57
|
-
@default false
|
|
58
|
-
@public
|
|
59
|
-
*/
|
|
60
39
|
isSettled: computed('isRejected', 'isFulfilled', function () {
|
|
61
40
|
return get(this, 'isRejected') || get(this, 'isFulfilled');
|
|
62
41
|
}).readOnly(),
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
Will become `true` if the proxied promise is rejected.
|
|
66
|
-
@property isRejected
|
|
67
|
-
@default false
|
|
68
|
-
@public
|
|
69
|
-
*/
|
|
70
42
|
isRejected: false,
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
Will become `true` if the proxied promise is fulfilled.
|
|
74
|
-
@property isFulfilled
|
|
75
|
-
@default false
|
|
76
|
-
@public
|
|
77
|
-
*/
|
|
78
43
|
isFulfilled: false,
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
The promise whose fulfillment value is being proxied by this object.
|
|
82
|
-
This property must be specified upon creation, and should not be
|
|
83
|
-
changed once created.
|
|
84
|
-
Example:
|
|
85
|
-
```javascript
|
|
86
|
-
import ObjectProxy from '@ember/object/proxy';
|
|
87
|
-
import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
|
|
88
|
-
ObjectProxy.extend(PromiseProxyMixin).create({
|
|
89
|
-
promise: <thenable>
|
|
90
|
-
});
|
|
91
|
-
```
|
|
92
|
-
@property promise
|
|
93
|
-
@public
|
|
94
|
-
*/
|
|
95
44
|
promise: computed({
|
|
96
45
|
get() {
|
|
97
46
|
throw new EmberError("PromiseProxy's promise must be set");
|
|
@@ -102,37 +51,8 @@ const PromiseProxyMixin = Mixin.create({
|
|
|
102
51
|
}
|
|
103
52
|
|
|
104
53
|
}),
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
An alias to the proxied promise's `then`.
|
|
108
|
-
See RSVP.Promise.then.
|
|
109
|
-
@method then
|
|
110
|
-
@param {Function} callback
|
|
111
|
-
@return {RSVP.Promise}
|
|
112
|
-
@public
|
|
113
|
-
*/
|
|
114
54
|
then: promiseAlias('then'),
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
An alias to the proxied promise's `catch`.
|
|
118
|
-
See RSVP.Promise.catch.
|
|
119
|
-
@method catch
|
|
120
|
-
@param {Function} callback
|
|
121
|
-
@return {RSVP.Promise}
|
|
122
|
-
@since 1.3.0
|
|
123
|
-
@public
|
|
124
|
-
*/
|
|
125
55
|
catch: promiseAlias('catch'),
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
An alias to the proxied promise's `finally`.
|
|
129
|
-
See RSVP.Promise.finally.
|
|
130
|
-
@method finally
|
|
131
|
-
@param {Function} callback
|
|
132
|
-
@return {RSVP.Promise}
|
|
133
|
-
@since 1.3.0
|
|
134
|
-
@public
|
|
135
|
-
*/
|
|
136
56
|
finally: promiseAlias('finally')
|
|
137
57
|
});
|
|
138
58
|
|
|
@@ -93,7 +93,7 @@ class Route extends EmberObject.extend(ActionHandler, Evented) {
|
|
|
93
93
|
let [name] = params;
|
|
94
94
|
assert('has name', name);
|
|
95
95
|
|
|
96
|
-
if (name in model) {
|
|
96
|
+
if (typeof model === 'object' && name in model) {
|
|
97
97
|
object[name] = get(model, name);
|
|
98
98
|
} else if (/_id$/.test(name)) {
|
|
99
99
|
object[name] = get(model, 'id');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default "4.9.0-alpha.
|
|
1
|
+
export default "4.9.0-alpha.4";
|