Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
ember-classic-decorator
Advanced tools
This addon provides a dev-time only class decorator, @classic
. This decorator
gets removed from production builds, and is entirely for the purpose of helping
you navigate the upgrade from Ember's classic class system to native classes
in Ember Octane!
First, install the addon:
ember install ember-classic-decorator
You should also ensure you are using the latest version of the Ember eslint plugin and enable the related eslint rules to gain the full benefits of the decorator:
// .eslintrc.js
// ...
rules: {
'ember/classic-decorator-hooks': 'error',
'ember/classic-decorator-no-classic-methods': 'error'
},
// ...
While you can now use native class syntax to extend from any Ember base class, there are still a few differences between classic classes and native classes that can be a little tricky during the conversion:
init
and constructor
are two separate methods that are called at different
times. If you convert a class to native class syntax and change its
init
function to constructor
, then it will run before any of its parent
classes' init
methods. This could leave you in an inconsistent state, and
cause subtle bugs.create
,
reopen
, and reopenClass
, which do not have native class equivalents. Some
classes will need to be redesigned to account for this.get
, set
,
incrementProperty
, and notifyPropertyChange
. In the future, most of these
methods will not be necessary, and will not exist on future base classes like
Glimmer components.@classic
provides a hint to you, the developer, that this class uses classic
APIs and base classes, and still has some work to do before it can be marked as
fully converted to Octane conventions.
When installed, @classic
will modify Ember classes to assert if certain APIs
are used, and lint against other APIs being used, unless a class is defined
with classic class syntax, or decorated with @classic
.
Certain classes must always be marked as classic:
EmberObject
These must be marked as classic because their APIs are intrinsically tied to the
classic class model. To remove the @classic
decorator from them, you can:
EmberObject
at all, and
only use native class syntax.Other classes can be converted incrementally to remove classic APIs, including:
In order to remove the classic decorator, you must:
reopen
and reopenClass
get
set
getProperties
setProperties
getWithDefault
incrementProperty
decrementProperty
toggleProperty
addObserver
removeObserver
notifyPropertyChange
Apply the @classic
decorator to any classes that should use classic APIs.
import EmberObject from '@ember/object';
import classic from 'ember-classic-decorator';
@classic
export default class Foo extends EmberObject {}
See the Contributing guide for details.
This project is licensed under the MIT License.
FAQs
Decorator to aide migration from classic class system to native classes
We found that ember-classic-decorator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.