I am used to computed properties in Ember Object Model. It\'s a convenient way to specify computed properties that depend on other properties.
Say fullName
What about something like this?
export const getWidgetsWithComputedProps = widgets => {
return widgets.map(w => getWidgetWithComputedProps(w));
};
export const selectWidgetType = widget => {
switch (widget.type) {
case 'line':
return 'time-series';
case 'pie':
case 'bar':
return 'cross-sectional';
default:
console.warn('Back up: that type of widget does not exist!', widget.type);
return null;
}
};
export const getWidgetWithComputedProps = createSelector(
widget => widget,
selectWidgetType,
(widget, _type) => {
return {...widget, _type}
}
);