File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
frameworks/keyed/react-mobX/src Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- var { observer} = require ( "mobx-react" ) ;
4
3
var { observable, computed, action} = require ( "mobx" ) ;
5
4
6
5
function _random ( max ) {
@@ -43,21 +42,21 @@ export class Store {
43
42
data . push ( row ( this , adjectives [ _random ( adjectives . length ) ] + " " + colours [ _random ( colours . length ) ] + " " + nouns [ _random ( nouns . length ) ] ) ) ;
44
43
return data ;
45
44
}
45
+
46
46
@action updateData ( mod = 10 ) {
47
47
for ( let i = 0 ; i < this . data . length ; i += 10 ) {
48
48
this . data [ i ] . label = this . data [ i ] . label + ' !!!' ;
49
49
}
50
50
}
51
51
@action delete ( row ) {
52
- const idx = this . data . indexOf ( row ) ;
53
- this . data . splice ( idx , 1 ) ;
52
+ this . data . remove ( row ) ;
54
53
}
55
54
@action run ( ) {
56
- this . data = this . buildData ( ) ;
55
+ this . data . replace ( this . buildData ( ) ) ;
57
56
this . selected = undefined ;
58
57
}
59
58
@action add ( ) {
60
- this . data = this . data . concat ( this . buildData ( 1000 ) ) ;
59
+ this . data . spliceWithArray ( this . data . length , 0 , this . buildData ( 1000 ) ) ;
61
60
}
62
61
@action update ( ) {
63
62
this . updateData ( ) ;
@@ -66,11 +65,11 @@ export class Store {
66
65
this . selected = row ;
67
66
}
68
67
@action runLots ( ) {
69
- this . data = this . buildData ( 10000 ) ;
68
+ this . data . replace ( this . buildData ( 10000 ) ) ;
70
69
this . selected = undefined ;
71
70
}
72
71
@action clear ( ) {
73
- this . data = [ ] ;
72
+ this . data . clear ( ) ;
74
73
this . selected = undefined ;
75
74
}
76
75
@action swapRows ( ) {
@@ -80,4 +79,4 @@ export class Store {
80
79
this . data [ 998 ] = a ;
81
80
}
82
81
}
83
- }
82
+ }
You can’t perform that action at this time.
0 commit comments