filters: combine filters first

This commit is contained in:
Nils Schneider 2015-07-08 21:17:00 +02:00
parent 036b6d6099
commit 653a329698
2 changed files with 10 additions and 6 deletions

View File

@ -1,4 +1,4 @@
define([], function () {
define(["filters/nodefilter"], function (NodeFilter) {
return function () {
var targets = []
var filterObservers = []
@ -26,9 +26,13 @@ define([], function () {
if (data === undefined)
return
filteredData = filters.reduce( function (a, f) {
return f.run(a)
}, data)
var filter = filters.reduce( function (a, f) {
return function (d) {
return a(d) && f.run(d)
}
}, function () { return true })
filteredData = new NodeFilter(filter)(data)
targets.forEach( function (t) {
t.setData(filteredData)

View File

@ -1,4 +1,4 @@
define(["filters/nodefilter"], function (nodefilter) {
define([], function () {
return function (name, key, value, f) {
var negate = false
var refresh
@ -44,7 +44,7 @@ define(["filters/nodefilter"], function (nodefilter) {
}
}
return { run: nodefilter(run),
return { run: run,
setRefresh: setRefresh,
render: render
}