Currently, I am using the ExtJS framework and running one method multiple times with different parameters.
I am seeking a more consistent, easy, and maintainable approach to handle this. Would vanilla Javascript solutions be the way to go?
I attempted to collect each param into an array and use methods like Array.map()
and forEach()
, but I have not been successful.
Thank you in advance.
//ExtJS class:
Ext.define('MyApp.FooClass', {
extend: 'Ext.panel.Panel',
items: [
MyApp.createFooCard('Func1Param1', 'Func1Param2', 'Func1Param3'),
MyApp.createFooCard('Func2Param1', 'Func2Param2', 'Func2Param3'),
MyApp.createFooCard('Func3Param1', 'Func3Param2', 'Func3Param3'),
]
});
It is evident that the same method is used with different arguments for each instance.
//And here is the related factory-function:
createFooCard: (bindValue, userCls, glyph, label) => {
return {
itemId: bindValue,
userCls: userCls,
glyph: MyApp.getGlyph(glyph),
items: {
xtype: 'infocardfld',
fieldLabel: label,
bind: '{' + bindValue + ' || "0"}'
}
}
}