darwin (owner)

Revisions

gist: 6249 Download_button fork
public
Public Clone URL: git://gist.github.com/6249.git
console output
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
FF3.0+FB1.2b13
 
C1: [] observer: [] 0
C1
A is empty
C1: [] observer: [] 0
C1: [] observer: [] 0
A has one item
C1: [] observer: [] 0
C1: [] observer: [] 0
A has two items
C2
A is empty
A has one item
A has two items
C3
A is empty
A has one item
A has two items
C2: [] observer: [] 0
C2: [] observer: [Object name=Object1, Object name=Object2] 2
C2: [] observer: [Object name=Object1, Object name=Object2] 2
C2: [] observer: [Object name=Object1, Object name=Object2] 2
C2: [] observer: [Object name=Object1, Object name=Object2] 2
C3: [] observer: [Object name=Object1, Object name=Object2] 2
C3: [] observer: [Object name=Object1, Object name=Object2] 2
C3: [] observer: [Object name=Object1, Object name=Object2] 2
C3: [] observer: [Object name=Object1, Object name=Object2] 2
C3: [] observer: [Object name=Object1, Object name=Object2] 2
 
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function main() {
  SC.page.awake();
  
  var arrayController = SC.ArrayController.create({
      exampleContentObject: "SC.Record",
      commitChangesImmediately: YES,
      content: [],
 
      _contentObserver: function() {
          var len = this.get('content').get('length');
          console.log('C1: [] observer:', this.get('content'), len);
      }.observes('[]')
  });
 
  var arrayController2 = SC.ArrayController.create({
      exampleContentObject: "SC.Record",
      commitChangesImmediately: YES,
      content: [],
 
      _contentObserver: function() {
          this._contentObserverWorker.bind(this).delay(0.001);
      }.observes('[]'),
 
      _contentObserverWorker: function() {
          var len = this.get('content').get('length');
          console.log('C2: [] observer:', this.get('content'), len);
      }
  });
 
  var arrayController3 = SC.ArrayController.create({
      exampleContentObject: "SC.Record",
      commitChangesImmediately: YES,
      content: [],
 
      _contentObserver: function() {
          this._contentObserverWorker.bind(this).delay(0.2);
      }.observes('[]'),
 
      _contentObserverWorker: function() {
          var len = this.get('content').get('length');
          console.log('C3: [] observer:', this.get('content'), len);
      }
  });
 
  console.log("C1");
  console.log("A is empty");
  arrayController.pushObject({name: "Object1"});
  console.log("A has one item");
  arrayController.pushObject({name: "Object2"});
  console.log("A has two items");
 
  console.log("C2");
  console.log("A is empty");
  arrayController2.pushObject({name: "Object1"});
  console.log("A has one item");
  arrayController2.pushObject({name: "Object2"});
  console.log("A has two items");
 
  console.log("C3");
  console.log("A is empty");
  arrayController3.pushObject({name: "Object1"});
  console.log("A has one item");
  arrayController3.pushObject({name: "Object2"});
  console.log("A has two items");
 
};