Toggle navigation
Toggle navigation
This project
Loading...
Sign in
arcs
/
arcs.js
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
3
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jean-Yves Didier
2021-12-17 16:01:38 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ee7f7e5e70f947ca6d598e512bbc2b71c2e590cf
ee7f7e5e
1 parent
3b4e15f1
created a filter class
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
components/filter.js
components/filter.js
0 → 100644
View file @
ee7f7e5
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
;
});
}
},
[],
[]
);
Please
register
or
login
to post a comment