-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CHORE] RFC-0329 - adding deprecation about using evented in ember-data
- Loading branch information
pete
committed
Apr 24, 2019
1 parent
67bf0b0
commit bacce7a
Showing
7 changed files
with
155 additions
and
27 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
packages/store/addon/-private/system/deprecated-evented.js
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,75 @@ | ||
import Evented from '@ember/object/evented'; | ||
import Mixin from '@ember/object/mixin'; | ||
import { deprecate } from '@ember/debug'; | ||
import { DEBUG } from '@glimmer/env'; | ||
|
||
let INSTANCE_DEPRECATIONS; | ||
let lookupDeprecations; | ||
let DeprecatedEvented; | ||
|
||
if (DEBUG) { | ||
INSTANCE_DEPRECATIONS = new WeakMap(); | ||
|
||
lookupDeprecations = function lookupInstanceDrecations(instance) { | ||
let deprecations = INSTANCE_DEPRECATIONS.get(instance); | ||
|
||
if (!deprecations) { | ||
deprecations = {}; | ||
INSTANCE_DEPRECATIONS.set(instance, deprecations); | ||
} | ||
|
||
return deprecations; | ||
}; | ||
|
||
DeprecatedEvented = Mixin.create(Evented, { | ||
/** | ||
* Provides a way to call Evented without logging deprecation warnings | ||
* @param {String} name | ||
*/ | ||
_has(name) { | ||
return Evented.mixins[0].properties.has.call(this, name); | ||
}, | ||
|
||
_deprecateEvented(eventName) { | ||
let deprecations = lookupDeprecations(this); | ||
const _deprecationData = this._getDeprecatedEventedInfo | ||
? `on ${this._getDeprecatedEventedInfo()}` | ||
: ''; | ||
const deprecationMessage = _deprecationData | ||
? `Called ${eventName} ${_deprecationData}` | ||
: eventName; | ||
deprecate(deprecationMessage, deprecations[eventName], { | ||
id: 'ember-evented', | ||
until: '3.12', | ||
}); | ||
deprecations[eventName] = true; | ||
}, | ||
|
||
has(name) { | ||
this._deprecateEvented(name); | ||
return this._super(...arguments); | ||
}, | ||
|
||
off(name, target, method) { | ||
this._deprecateEvented(name); | ||
return this._super(...arguments); | ||
}, | ||
|
||
on(name, target, method) { | ||
this._deprecateEvented(name); | ||
return this._super(...arguments); | ||
}, | ||
|
||
one(name, target, method) { | ||
this._deprecateEvented(name); | ||
return this._super(...arguments); | ||
}, | ||
|
||
trigger(name) { | ||
this._deprecateEvented(name); | ||
return this._super(...arguments); | ||
}, | ||
}); | ||
} | ||
|
||
export default (DEBUG ? DeprecatedEvented : Evented); |
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