ember-source 4.5.0-alpha.3 → 4.5.0-beta.1

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/build-metadata.json +3 -3
  3. package/dist/dependencies/@glimmer/global-context.js +9 -1
  4. package/dist/dependencies/@glimmer/manager.js +276 -212
  5. package/dist/dependencies/@glimmer/runtime.js +2 -2
  6. package/dist/dependencies/@glimmer/util.js +1 -22
  7. package/dist/ember-template-compiler.js +37 -30
  8. package/dist/ember-template-compiler.map +1 -1
  9. package/dist/ember-testing.js +1 -1
  10. package/dist/ember-testing.map +1 -1
  11. package/dist/ember.debug.js +1204 -1431
  12. package/dist/ember.debug.map +1 -1
  13. package/dist/header/license.js +1 -1
  14. package/dist/packages/@ember/-internals/container/index.js +2 -2
  15. package/dist/packages/@ember/-internals/glimmer/index.js +24 -19
  16. package/dist/packages/@ember/-internals/metal/index.js +19 -7
  17. package/dist/packages/@ember/-internals/routing/lib/location/api.js +3 -3
  18. package/dist/packages/@ember/-internals/routing/lib/location/auto_location.js +5 -1
  19. package/dist/packages/@ember/-internals/routing/lib/services/router.js +7 -6
  20. package/dist/packages/@ember/-internals/routing/lib/services/routing.js +9 -6
  21. package/dist/packages/@ember/-internals/routing/lib/system/route.js +6 -9
  22. package/dist/packages/@ember/-internals/routing/lib/system/router.js +4 -2
  23. package/dist/packages/@ember/-internals/routing/lib/utils.js +15 -25
  24. package/dist/packages/@ember/-internals/runtime/lib/compare.js +4 -1
  25. package/dist/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +14 -15
  26. package/dist/packages/@ember/-internals/runtime/lib/mixins/action_handler.js +32 -44
  27. package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +1 -1
  28. package/dist/packages/@ember/-internals/runtime/lib/mixins/comparable.js +7 -22
  29. package/dist/packages/@ember/-internals/runtime/lib/mixins/container_proxy.js +34 -46
  30. package/dist/packages/@ember/-internals/runtime/lib/mixins/enumerable.js +2 -15
  31. package/dist/packages/@ember/-internals/runtime/lib/mixins/evented.js +13 -57
  32. package/dist/packages/@ember/-internals/runtime/lib/mixins/mutable_enumerable.js +2 -16
  33. package/dist/packages/@ember/-internals/runtime/lib/mixins/observable.js +64 -134
  34. package/dist/packages/@ember/-internals/runtime/lib/mixins/promise_proxy.js +28 -86
  35. package/dist/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +59 -61
  36. package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +17 -24
  37. package/dist/packages/@ember/-internals/runtime/lib/system/array_proxy.js +59 -85
  38. package/dist/packages/@ember/-internals/runtime/lib/system/object.js +9 -2
  39. package/dist/packages/@ember/-internals/runtime/lib/system/object_proxy.js +3 -77
  40. package/dist/packages/@ember/-internals/utils/index.js +1 -1
  41. package/dist/packages/@ember/-internals/utils/types.js +1 -0
  42. package/dist/packages/@ember/-internals/views/lib/compat/attrs.js +1 -2
  43. package/dist/packages/@ember/-internals/views/lib/component_lookup.js +2 -2
  44. package/dist/packages/@ember/-internals/views/lib/mixins/action_support.js +3 -9
  45. package/dist/packages/@ember/-internals/views/lib/mixins/child_views_support.js +4 -6
  46. package/dist/packages/@ember/-internals/views/lib/mixins/class_names_support.js +13 -18
  47. package/dist/packages/@ember/-internals/views/lib/mixins/view_state_support.js +3 -2
  48. package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +57 -58
  49. package/dist/packages/@ember/-internals/views/lib/system/event_dispatcher.js +142 -120
  50. package/dist/packages/@ember/-internals/views/lib/system/utils.js +1 -1
  51. package/dist/packages/@ember/-internals/views/lib/views/states/destroying.js +1 -1
  52. package/dist/packages/@ember/-internals/views/lib/views/states/has_element.js +2 -2
  53. package/dist/packages/@ember/-internals/views/lib/views/states/in_dom.js +3 -1
  54. package/dist/packages/@ember/application/instance.js +1 -0
  55. package/dist/packages/@ember/application/lib/application.js +8 -1
  56. package/dist/packages/@ember/canary-features/index.js +6 -4
  57. package/dist/packages/@ember/engine/instance.js +1 -1
  58. package/dist/packages/@ember/engine/lib/engine-parent.js +1 -5
  59. package/dist/packages/@ember/renderer/index.js +28 -0
  60. package/dist/packages/ember/version.js +1 -1
  61. package/docs/data.json +823 -709
  62. package/package.json +16 -16
@@ -4,105 +4,34 @@
4
4
  import { peekMeta } from '@ember/-internals/meta';
5
5
  import { get, set, getProperties, setProperties, Mixin, hasListeners, beginPropertyChanges, notifyPropertyChange, endPropertyChanges, addObserver, removeObserver } from '@ember/-internals/metal';
6
6
  import { assert } from '@ember/debug';
7
- /**
8
- ## Overview
9
-
10
- This mixin provides properties and property observing functionality, core
11
- features of the Ember object model.
12
-
13
- Properties and observers allow one object to observe changes to a
14
- property on another object. This is one of the fundamental ways that
15
- models, controllers and views communicate with each other in an Ember
16
- application.
17
-
18
- Any object that has this mixin applied can be used in observer
19
- operations. That includes `EmberObject` and most objects you will
20
- interact with as you write your Ember application.
21
-
22
- Note that you will not generally apply this mixin to classes yourself,
23
- but you will use the features provided by this module frequently, so it
24
- is important to understand how to use it.
25
-
26
- ## Using `get()` and `set()`
27
-
28
- Because of Ember's support for bindings and observers, you will always
29
- access properties using the get method, and set properties using the
30
- set method. This allows the observing objects to be notified and
31
- computed properties to be handled properly.
32
-
33
- More documentation about `get` and `set` are below.
34
-
35
- ## Observing Property Changes
36
-
37
- You typically observe property changes simply by using the `observer`
38
- function in classes that you write.
39
-
40
- For example:
41
-
42
- ```javascript
43
- import { observer } from '@ember/object';
44
- import EmberObject from '@ember/object';
45
-
46
- EmberObject.extend({
47
- valueObserver: observer('value', function(sender, key, value, rev) {
48
- // Executes whenever the "value" property changes
49
- // See the addObserver method for more information about the callback arguments
50
- })
51
- });
52
- ```
53
-
54
- Although this is the most common way to add an observer, this capability
55
- is actually built into the `EmberObject` class on top of two methods
56
- defined in this mixin: `addObserver` and `removeObserver`. You can use
57
- these two methods to add and remove observers yourself if you need to
58
- do so at runtime.
59
-
60
- To add an observer for a property, call:
61
-
62
- ```javascript
63
- object.addObserver('propertyKey', targetObject, targetAction)
64
- ```
65
-
66
- This will call the `targetAction` method on the `targetObject` whenever
67
- the value of the `propertyKey` changes.
68
-
69
- Note that if `propertyKey` is a computed property, the observer will be
70
- called when any of the property dependencies are changed, even if the
71
- resulting value of the computed property is unchanged. This is necessary
72
- because computed properties are not computed until `get` is called.
73
-
74
- @class Observable
75
- @public
76
- */
77
-
78
- export default Mixin.create({
7
+ const Observable = Mixin.create({
79
8
  /**
80
9
  Retrieves the value of a property from the object.
81
- This method is usually similar to using `object[keyName]` or `object.keyName`,
10
+ This method is usually similar to using `object[keyName]` or `object.keyName`,
82
11
  however it supports both computed properties and the unknownProperty
83
12
  handler.
84
- Because `get` unifies the syntax for accessing all these kinds
13
+ Because `get` unifies the syntax for accessing all these kinds
85
14
  of properties, it can make many refactorings easier, such as replacing a
86
15
  simple property with a computed property, or vice versa.
87
- ### Computed Properties
88
- Computed properties are methods defined with the `property` modifier
16
+ ### Computed Properties
17
+ Computed properties are methods defined with the `property` modifier
89
18
  declared at the end, such as:
90
- ```javascript
19
+ ```javascript
91
20
  import { computed } from '@ember/object';
92
- fullName: computed('firstName', 'lastName', function() {
21
+ fullName: computed('firstName', 'lastName', function() {
93
22
  return this.get('firstName') + ' ' + this.get('lastName');
94
23
  })
95
24
  ```
96
- When you call `get` on a computed property, the function will be
25
+ When you call `get` on a computed property, the function will be
97
26
  called and the return value will be returned instead of the function
98
27
  itself.
99
- ### Unknown Properties
100
- Likewise, if you try to call `get` on a property whose value is
28
+ ### Unknown Properties
29
+ Likewise, if you try to call `get` on a property whose value is
101
30
  `undefined`, the `unknownProperty()` method will be called on the object.
102
31
  If this method returns any value other than `undefined`, it will be returned
103
32
  instead. This allows you to implement "virtual" properties that are
104
33
  not defined upfront.
105
- @method get
34
+ @method get
106
35
  @param {String} keyName The property to retrieve
107
36
  @return {Object} The property value or undefined.
108
37
  @public
@@ -114,54 +43,54 @@ export default Mixin.create({
114
43
  /**
115
44
  To get the values of multiple properties at once, call `getProperties`
116
45
  with a list of strings or an array:
117
- ```javascript
46
+ ```javascript
118
47
  record.getProperties('firstName', 'lastName', 'zipCode');
119
48
  // { firstName: 'John', lastName: 'Doe', zipCode: '10011' }
120
49
  ```
121
- is equivalent to:
122
- ```javascript
50
+ is equivalent to:
51
+ ```javascript
123
52
  record.getProperties(['firstName', 'lastName', 'zipCode']);
124
53
  // { firstName: 'John', lastName: 'Doe', zipCode: '10011' }
125
54
  ```
126
- @method getProperties
55
+ @method getProperties
127
56
  @param {String...|Array} list of keys to get
128
57
  @return {Object}
129
58
  @public
130
59
  */
131
60
  getProperties(...args) {
132
- return getProperties(...[this].concat(args));
61
+ return getProperties(this, ...args);
133
62
  },
134
63
 
135
64
  /**
136
65
  Sets the provided key or path to the value.
137
- ```javascript
66
+ ```javascript
138
67
  record.set("key", value);
139
68
  ```
140
- This method is generally very similar to calling `object["key"] = value` or
69
+ This method is generally very similar to calling `object["key"] = value` or
141
70
  `object.key = value`, except that it provides support for computed
142
71
  properties, the `setUnknownProperty()` method and property observers.
143
- ### Computed Properties
144
- If you try to set a value on a key that has a computed property handler
72
+ ### Computed Properties
73
+ If you try to set a value on a key that has a computed property handler
145
74
  defined (see the `get()` method for an example), then `set()` will call
146
75
  that method, passing both the value and key instead of simply changing
147
76
  the value itself. This is useful for those times when you need to
148
77
  implement a property that is composed of one or more member
149
78
  properties.
150
- ### Unknown Properties
151
- If you try to set a value on a key that is undefined in the target
79
+ ### Unknown Properties
80
+ If you try to set a value on a key that is undefined in the target
152
81
  object, then the `setUnknownProperty()` handler will be called instead. This
153
82
  gives you an opportunity to implement complex "virtual" properties that
154
83
  are not predefined on the object. If `setUnknownProperty()` returns
155
84
  undefined, then `set()` will simply set the value on the object.
156
- ### Property Observers
157
- In addition to changing the property, `set()` will also register a property
85
+ ### Property Observers
86
+ In addition to changing the property, `set()` will also register a property
158
87
  change with the object. Unless you have placed this call inside of a
159
88
  `beginPropertyChanges()` and `endPropertyChanges(),` any "local" observers
160
89
  (i.e. observer methods declared on the same object), will be called
161
90
  immediately. Any "remote" observers (i.e. observer methods declared on
162
91
  another object) will be placed in a queue and called at a later time in a
163
92
  coalesced manner.
164
- @method set
93
+ @method set
165
94
  @param {String} keyName The property to set
166
95
  @param {Object} value The value to set or `null`.
167
96
  @return {Object} The passed value
@@ -175,10 +104,10 @@ export default Mixin.create({
175
104
  Sets a list of properties at once. These properties are set inside
176
105
  a single `beginPropertyChanges` and `endPropertyChanges` batch, so
177
106
  observers will be buffered.
178
- ```javascript
107
+ ```javascript
179
108
  record.setProperties({ firstName: 'Charles', lastName: 'Jolley' });
180
109
  ```
181
- @method setProperties
110
+ @method setProperties
182
111
  @param {Object} hash the hash of keys and values to set
183
112
  @return {Object} The passed in hash
184
113
  @public
@@ -189,14 +118,14 @@ export default Mixin.create({
189
118
 
190
119
  /**
191
120
  Begins a grouping of property changes.
192
- You can use this method to group property changes so that notifications
121
+ You can use this method to group property changes so that notifications
193
122
  will not be sent until the changes are finished. If you plan to make a
194
123
  large number of changes to an object at one time, you should call this
195
124
  method at the beginning of the changes to begin deferring change
196
125
  notifications. When you are done making changes, call
197
126
  `endPropertyChanges()` to deliver the deferred change notifications and end
198
127
  deferring.
199
- @method beginPropertyChanges
128
+ @method beginPropertyChanges
200
129
  @return {Observable}
201
130
  @private
202
131
  */
@@ -207,13 +136,13 @@ export default Mixin.create({
207
136
 
208
137
  /**
209
138
  Ends a grouping of property changes.
210
- You can use this method to group property changes so that notifications
139
+ You can use this method to group property changes so that notifications
211
140
  will not be sent until the changes are finished. If you plan to make a
212
141
  large number of changes to an object at one time, you should call
213
142
  `beginPropertyChanges()` at the beginning of the changes to defer change
214
143
  notifications. When you are done making changes, call this method to
215
144
  deliver the deferred change notifications and end deferring.
216
- @method endPropertyChanges
145
+ @method endPropertyChanges
217
146
  @return {Observable}
218
147
  @private
219
148
  */
@@ -224,11 +153,11 @@ export default Mixin.create({
224
153
 
225
154
  /**
226
155
  Notify the observer system that a property has just changed.
227
- Sometimes you need to change a value directly or indirectly without
156
+ Sometimes you need to change a value directly or indirectly without
228
157
  actually calling `get()` or `set()` on it. In this case, you can use this
229
158
  method instead. Calling this method will notify all observers that the
230
159
  property has potentially changed value.
231
- @method notifyPropertyChange
160
+ @method notifyPropertyChange
232
161
  @param {String} keyName The property key to be notified about.
233
162
  @return {Observable}
234
163
  @public
@@ -240,13 +169,13 @@ export default Mixin.create({
240
169
 
241
170
  /**
242
171
  Adds an observer on a property.
243
- This is the core method used to register an observer for a property.
244
- Once you call this method, any time the key's value is set, your observer
172
+ This is the core method used to register an observer for a property.
173
+ Once you call this method, any time the key's value is set, your observer
245
174
  will be notified. Note that the observers are triggered any time the
246
175
  value is set, regardless of whether it has actually changed. Your
247
176
  observer should be prepared to handle that.
248
- There are two common invocation patterns for `.addObserver()`:
249
- - Passing two arguments:
177
+ There are two common invocation patterns for `.addObserver()`:
178
+ - Passing two arguments:
250
179
  - the name of the property to observe (as a string)
251
180
  - the function to invoke (an actual function)
252
181
  - Passing three arguments:
@@ -255,47 +184,47 @@ export default Mixin.create({
255
184
  function on)
256
185
  - the name of the function to invoke on the target object
257
186
  (as a string).
258
- ```app/components/my-component.js
187
+ ```app/components/my-component.js
259
188
  import Component from '@ember/component';
260
- export default Component.extend({
189
+ export default Component.extend({
261
190
  init() {
262
191
  this._super(...arguments);
263
- // the following are equivalent:
264
- // using three arguments
192
+ // the following are equivalent:
193
+ // using three arguments
265
194
  this.addObserver('foo', this, 'fooDidChange');
266
- // using two arguments
195
+ // using two arguments
267
196
  this.addObserver('foo', (...args) => {
268
197
  this.fooDidChange(...args);
269
198
  });
270
199
  },
271
- fooDidChange() {
200
+ fooDidChange() {
272
201
  // your custom logic code
273
202
  }
274
203
  });
275
204
  ```
276
- ### Observer Methods
277
- Observer methods have the following signature:
278
- ```app/components/my-component.js
205
+ ### Observer Methods
206
+ Observer methods have the following signature:
207
+ ```app/components/my-component.js
279
208
  import Component from '@ember/component';
280
- export default Component.extend({
209
+ export default Component.extend({
281
210
  init() {
282
211
  this._super(...arguments);
283
212
  this.addObserver('foo', this, 'fooDidChange');
284
213
  },
285
- fooDidChange(sender, key, value, rev) {
214
+ fooDidChange(sender, key, value, rev) {
286
215
  // your code
287
216
  }
288
217
  });
289
218
  ```
290
- The `sender` is the object that changed. The `key` is the property that
219
+ The `sender` is the object that changed. The `key` is the property that
291
220
  changes. The `value` property is currently reserved and unused. The `rev`
292
221
  is the last property revision of the object when it changed, which you can
293
222
  use to detect if the key value has really changed or not.
294
- Usually you will not need the value or revision parameters at
223
+ Usually you will not need the value or revision parameters at
295
224
  the end. In this case, it is common to write observer methods that take
296
225
  only a sender and key value as parameters or, if you aren't interested in
297
226
  any of these values, to write an observer that has no parameters at all.
298
- @method addObserver
227
+ @method addObserver
299
228
  @param {String} key The key to observe
300
229
  @param {Object} target The target object to invoke
301
230
  @param {String|Function} method The method to invoke
@@ -312,7 +241,7 @@ export default Mixin.create({
312
241
  Remove an observer you have previously registered on this object. Pass
313
242
  the same key, target, and method you passed to `addObserver()` and your
314
243
  target will no longer receive notifications.
315
- @method removeObserver
244
+ @method removeObserver
316
245
  @param {String} key The key to observe
317
246
  @param {Object} target The target object to invoke
318
247
  @param {String|Function} method The method to invoke
@@ -330,7 +259,7 @@ export default Mixin.create({
330
259
  particular key. You can use this method to potentially defer performing
331
260
  an expensive action until someone begins observing a particular property
332
261
  on the object.
333
- @method hasObserverFor
262
+ @method hasObserverFor
334
263
  @param {String} key Key to check
335
264
  @return {Boolean}
336
265
  @private
@@ -341,45 +270,45 @@ export default Mixin.create({
341
270
 
342
271
  /**
343
272
  Set the value of a property to the current value plus some amount.
344
- ```javascript
273
+ ```javascript
345
274
  person.incrementProperty('age');
346
275
  team.incrementProperty('score', 2);
347
276
  ```
348
- @method incrementProperty
277
+ @method incrementProperty
349
278
  @param {String} keyName The name of the property to increment
350
279
  @param {Number} increment The amount to increment by. Defaults to 1
351
280
  @return {Number} The new property value
352
281
  @public
353
282
  */
354
283
  incrementProperty(keyName, increment = 1) {
355
- assert('Must pass a numeric value to incrementProperty', !isNaN(parseFloat(increment)) && isFinite(increment));
284
+ assert('Must pass a numeric value to incrementProperty', !isNaN(parseFloat(String(increment))) && isFinite(increment));
356
285
  return set(this, keyName, (parseFloat(get(this, keyName)) || 0) + increment);
357
286
  },
358
287
 
359
288
  /**
360
289
  Set the value of a property to the current value minus some amount.
361
- ```javascript
290
+ ```javascript
362
291
  player.decrementProperty('lives');
363
292
  orc.decrementProperty('health', 5);
364
293
  ```
365
- @method decrementProperty
294
+ @method decrementProperty
366
295
  @param {String} keyName The name of the property to decrement
367
296
  @param {Number} decrement The amount to decrement by. Defaults to 1
368
297
  @return {Number} The new property value
369
298
  @public
370
299
  */
371
300
  decrementProperty(keyName, decrement = 1) {
372
- assert('Must pass a numeric value to decrementProperty', !isNaN(parseFloat(decrement)) && isFinite(decrement));
301
+ assert('Must pass a numeric value to decrementProperty', (typeof decrement === 'number' || !isNaN(parseFloat(decrement))) && isFinite(decrement));
373
302
  return set(this, keyName, (get(this, keyName) || 0) - decrement);
374
303
  },
375
304
 
376
305
  /**
377
306
  Set the value of a boolean property to the opposite of its
378
307
  current value.
379
- ```javascript
308
+ ```javascript
380
309
  starship.toggleProperty('warpDriveEngaged');
381
310
  ```
382
- @method toggleProperty
311
+ @method toggleProperty
383
312
  @param {String} keyName The name of the property to toggle
384
313
  @return {Boolean} The new property value
385
314
  @public
@@ -393,7 +322,7 @@ export default Mixin.create({
393
322
  This allows you to inspect the value of a computed property
394
323
  without accidentally invoking it if it is intended to be
395
324
  generated lazily.
396
- @method cacheFor
325
+ @method cacheFor
397
326
  @param {String} keyName
398
327
  @return {Object} The cached value of the computed property, if any
399
328
  @public
@@ -406,4 +335,5 @@ export default Mixin.create({
406
335
  }
407
336
  }
408
337
 
409
- });
338
+ });
339
+ export default Observable;
@@ -29,76 +29,12 @@ function tap(proxy, promise) {
29
29
  throw reason;
30
30
  }, 'Ember: PromiseProxy');
31
31
  }
32
- /**
33
- A low level mixin making ObjectProxy promise-aware.
34
-
35
- ```javascript
36
- import { resolve } from 'rsvp';
37
- import $ from 'jquery';
38
- import ObjectProxy from '@ember/object/proxy';
39
- import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
40
-
41
- let ObjectPromiseProxy = ObjectProxy.extend(PromiseProxyMixin);
42
-
43
- let proxy = ObjectPromiseProxy.create({
44
- promise: resolve($.getJSON('/some/remote/data.json'))
45
- });
46
-
47
- proxy.then(function(json){
48
- // the json
49
- }, function(reason) {
50
- // the reason why you have no json
51
- });
52
- ```
53
-
54
- the proxy has bindable attributes which
55
- track the promises life cycle
56
-
57
- ```javascript
58
- proxy.get('isPending') //=> true
59
- proxy.get('isSettled') //=> false
60
- proxy.get('isRejected') //=> false
61
- proxy.get('isFulfilled') //=> false
62
- ```
63
-
64
- When the $.getJSON completes, and the promise is fulfilled
65
- with json, the life cycle attributes will update accordingly.
66
- Note that $.getJSON doesn't return an ECMA specified promise,
67
- it is useful to wrap this with an `RSVP.resolve` so that it behaves
68
- as a spec compliant promise.
69
-
70
- ```javascript
71
- proxy.get('isPending') //=> false
72
- proxy.get('isSettled') //=> true
73
- proxy.get('isRejected') //=> false
74
- proxy.get('isFulfilled') //=> true
75
- ```
76
-
77
- As the proxy is an ObjectProxy, and the json now its content,
78
- all the json properties will be available directly from the proxy.
79
-
80
- ```javascript
81
- // Assuming the following json:
82
- {
83
- firstName: 'Stefan',
84
- lastName: 'Penner'
85
- }
86
-
87
- // both properties will accessible on the proxy
88
- proxy.get('firstName') //=> 'Stefan'
89
- proxy.get('lastName') //=> 'Penner'
90
- ```
91
-
92
- @class PromiseProxyMixin
93
- @public
94
- */
95
-
96
32
 
97
- export default Mixin.create({
33
+ const PromiseProxyMixin = Mixin.create({
98
34
  /**
99
35
  If the proxied promise is rejected this will contain the reason
100
36
  provided.
101
- @property reason
37
+ @property reason
102
38
  @default null
103
39
  @public
104
40
  */
@@ -106,7 +42,7 @@ export default Mixin.create({
106
42
 
107
43
  /**
108
44
  Once the proxied promise has settled this will become `false`.
109
- @property isPending
45
+ @property isPending
110
46
  @default true
111
47
  @public
112
48
  */
@@ -116,7 +52,7 @@ export default Mixin.create({
116
52
 
117
53
  /**
118
54
  Once the proxied promise has settled this will become `true`.
119
- @property isSettled
55
+ @property isSettled
120
56
  @default false
121
57
  @public
122
58
  */
@@ -126,7 +62,7 @@ export default Mixin.create({
126
62
 
127
63
  /**
128
64
  Will become `true` if the proxied promise is rejected.
129
- @property isRejected
65
+ @property isRejected
130
66
  @default false
131
67
  @public
132
68
  */
@@ -134,7 +70,7 @@ export default Mixin.create({
134
70
 
135
71
  /**
136
72
  Will become `true` if the proxied promise is fulfilled.
137
- @property isFulfilled
73
+ @property isFulfilled
138
74
  @default false
139
75
  @public
140
76
  */
@@ -142,17 +78,17 @@ export default Mixin.create({
142
78
 
143
79
  /**
144
80
  The promise whose fulfillment value is being proxied by this object.
145
- This property must be specified upon creation, and should not be
81
+ This property must be specified upon creation, and should not be
146
82
  changed once created.
147
- Example:
148
- ```javascript
83
+ Example:
84
+ ```javascript
149
85
  import ObjectProxy from '@ember/object/proxy';
150
86
  import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
151
- ObjectProxy.extend(PromiseProxyMixin).create({
87
+ ObjectProxy.extend(PromiseProxyMixin).create({
152
88
  promise: <thenable>
153
89
  });
154
90
  ```
155
- @property promise
91
+ @property promise
156
92
  @public
157
93
  */
158
94
  promise: computed({
@@ -160,7 +96,7 @@ export default Mixin.create({
160
96
  throw new EmberError("PromiseProxy's promise must be set");
161
97
  },
162
98
 
163
- set(key, promise) {
99
+ set(_key, promise) {
164
100
  return tap(this, promise);
165
101
  }
166
102
 
@@ -168,8 +104,8 @@ export default Mixin.create({
168
104
 
169
105
  /**
170
106
  An alias to the proxied promise's `then`.
171
- See RSVP.Promise.then.
172
- @method then
107
+ See RSVP.Promise.then.
108
+ @method then
173
109
  @param {Function} callback
174
110
  @return {RSVP.Promise}
175
111
  @public
@@ -178,8 +114,8 @@ export default Mixin.create({
178
114
 
179
115
  /**
180
116
  An alias to the proxied promise's `catch`.
181
- See RSVP.Promise.catch.
182
- @method catch
117
+ See RSVP.Promise.catch.
118
+ @method catch
183
119
  @param {Function} callback
184
120
  @return {RSVP.Promise}
185
121
  @since 1.3.0
@@ -189,8 +125,8 @@ export default Mixin.create({
189
125
 
190
126
  /**
191
127
  An alias to the proxied promise's `finally`.
192
- See RSVP.Promise.finally.
193
- @method finally
128
+ See RSVP.Promise.finally.
129
+ @method finally
194
130
  @param {Function} callback
195
131
  @return {RSVP.Promise}
196
132
  @since 1.3.0
@@ -200,8 +136,14 @@ export default Mixin.create({
200
136
  });
201
137
 
202
138
  function promiseAlias(name) {
203
- return function () {
204
- let promise = get(this, 'promise');
205
- return promise[name](...arguments);
139
+ return function (...args) {
140
+ let promise = get(this, 'promise'); // We need this cast because `Parameters` is deferred so that it is not
141
+ // possible for TS to see it will always produce the right type. However,
142
+ // since `AnyFn` has a rest type, it is allowed. See discussion on [this
143
+ // issue](https://github.com/microsoft/TypeScript/issues/47615).
144
+
145
+ return promise[name](...args);
206
146
  };
207
- }
147
+ }
148
+
149
+ export default PromiseProxyMixin;