Jean-Yves Didier

created a filter class

import * as ARCS from '../build/arcs.js';
let Filter;
/**
* @class Filter
* @classdesc Creates a filter in between a signal and a slot
*
* The idea is to create a dynamic component with a slot list and signals
* so that data is adapted, on the fly, by the component.
* In a way, it is similar to filters in pipe|filter architectures.
*
* @param config {FilterConfig} configuration object to initialize filter
*/
Filter = ARCS.Component.create(
/** @lends Filter.prototype */
function(config) {
let self = this;
let _config = config || {};
if (_config.signals) {
_config.signals.forEach(e => {
if (self.signals.indexOf(e) < 0) self.signals.push(e);
});
}
if (_config.slots) {
_config.slots.forEach(e => {
if (!e.slot || !e.func) return;
let slotName = e.slot;
let slotFunc = new Function('self',`return ${e.func}`)(self);
self.slots.push(slotName);
self[slotName] = slotFunc;
});
}
},
[],
[]
);