I'm following magento 2 official documentation to create my checkout step. I'm very new to knockoutjs, requirejs, js components which are massively used in magento 2, specially in checkout.
I'm struggling to understand the concept of mixins, extending and overriding js in magento.
I have seen somewhere earlier
map
was used to override js file. Now here mixins is used and seem to me to serve similar purpose.
In that documentation in this code section of viewModel:
define(
[
'ko'
], function (ko) {
'use strict';
var mixin = {
initialize: function () {
this.visible = ko.observable(false); // set visible to be initially false to have your step show first
this._super();
return this;
}
};
return function (target) {
return target.extend(mixin);
};
}
);
target is passed to a function, which is returned from the viewModel, at last, it further extends itself with mixin model. I'm confused here as well, where does target come from and what is being returned actually.
In short, my question is what is the difference between mixin and map, and explanation to the viewModel.