Skip to content

Commit 6775f3b

Browse files
committed
Only one array of collectors instead of two
1 parent a4c7126 commit 6775f3b

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

src/api/collect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

22
dop.collect = function(filter) {
33
dop.util.invariant(arguments.length===0 || (arguments.length>0 && isFunction(filter)), 'dop.collect only accept one argument as function');
4-
return dop.core.createCollector(dop.data.collectors[0], dop.data.collectors[0].length, filter);
4+
return dop.core.createCollector(dop.data.collectors, dop.data.collectors.length, filter);
55
};

src/api/collectFirst.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

22
dop.collectFirst = function(filter) {
33
dop.util.invariant(arguments.length===0 || (arguments.length>0 && isFunction(filter)), 'dop.collectFirst only accept one argument as function');
4-
return dop.core.createCollector(dop.data.collectors[0], 0, filter);
4+
return dop.core.createCollector(dop.data.collectors, 0, filter);
55
};

src/core/objects/storeMutation.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22
dop.core.storeMutation = function(mutation) {
33

44
var collectors = dop.data.collectors,
5-
index=0, total=collectors.length, index2=0, total2;
5+
index=0,
6+
total=collectors.length;
67

8+
// Saving path_id
79
mutation.path_id = dop.core.getPathId(
810
(mutation.splice!==undefined || mutation.swaps!==undefined) ?
911
mutation.path
1012
:
1113
mutation.path.concat(mutation.prop)
1214
);
1315

16+
1417
// Running collectors
1518
for (;index<total; index++)
16-
if (collectors[index].length > 0)
17-
for (index2=0,total2=collectors[index].length; index2<total2; index2++)
18-
if (collectors[index][index2].add(mutation))
19-
return dop.core.runDerivations(mutation.path_id);
19+
if (collectors[index].add(mutation))
20+
return dop.core.runDerivations(mutation.path_id);
21+
2022

2123
var snapshot = new dop.core.snapshot([mutation]);
2224
snapshot.emit();

src/dop.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,27 @@ var dop = {
66

77
// Internal data
88
data: {
9-
node_inc:0,
10-
node:{},
11-
object_inc:1,
12-
object:{},
13-
collectors:[[],[]],
14-
observers:{},
15-
observers_inc:0,
16-
gets_collecting:false,
9+
node_inc: 0,
10+
node: {},
11+
12+
object_inc: 1,
13+
object: {},
14+
15+
collectors: [],
16+
17+
gets_collecting: false,
1718
gets_paths: [],
1819

20+
observers_inc: 0,
21+
observers: {},
22+
1923
computed_inc: 0,
2024
computed: {},
25+
2126
path: {
2227
// computeds: []
2328
// derivations: []
29+
// observers: []
2430
}
2531
},
2632

0 commit comments

Comments
 (0)