i am have viewModel:
Ext.define('Shop.view.BooksViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.booksVM',
stores: {
books: {
model: 'Poly.model.books',
extend: 'Ext.data.Store',
listeners: {
update: function() {
// get this view model for set record in 'getBooks' formula
}
}
}
},
formulas: {
getBooks: {
get: function (value) {
return value;
}
}
}})
and in 'update' function in store i am want get this viewModel and set in formula record. But if i am call 'this' inside store fucntion i am get 'store'
Use initConfig mehod.
Ext.define('Shop.view.BooksViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.booksVM',
initConfig: function(instanceConfig) {
var me = this,
config = {
stores: {
books: {
model: 'Poly.model.books',
extend: 'Ext.data.Store',
listeners: {
update: function() {
console.log(me.getFormulas().getBooks);
}
}
}
}
};
if (instanceConfig) {
me.getConfigurator().merge(me, config, instanceConfig);
}
return me.callParent([config]);
},
formulas: {
getBooks: {
get: function (value) {
return value;
}
}
}})