Using ember-cli and its ES6 module transpiler how and where would one define this so that would apply to all Arrays in my App:
Array.prototype.move = function (old_index, new_index) {
....
};
You have a few options.
Add a file to the vendor/ directory with your extensions and include it in your Brocfile.js like so:
app.import('vendor/my-prototype-extensions.js');
Do it in an initializer.
ember g initializer extensions
Then in app/initializers/extension.js add your extensions like so
export var initialize = function() {
Array.prototype.move = function (old_index, new_index) {
....
};
}
export default {
name: 'extensions',
initialize: initialize
}
I personally prefer the initializer approach as it's being done in the ember-cli ecosystem so you have access to anything available there if you need it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With