@@ -11,31 +11,42 @@ var (
11
11
vMap = make (map [interface {}]* ViewModel , 0 )
12
12
)
13
13
14
- // type Value represents the VueJS wrapped observed Array or Object
15
- // the wrapped methods can be used to trigger view update.
16
- // `*Value` is usually returned by calling `ViewModel.Get()`
17
- type Value struct {
18
- /////// Normal value operation as js.Object
19
- * js.Object
14
+ // Add in the bottom of the array
15
+ func Push (obj * js.Object , any interface {}) (idx int ) {
16
+ return obj .Call ("push" , any ).Int ()
17
+ }
18
+
19
+ // Remove in the bottom of the array
20
+ func Pop (obj * js.Object ) (idx int ) {
21
+ return obj .Call ("pop" ).Int ()
22
+ }
23
+
24
+ //Add in the front of the array
25
+ func Unshift (obj * js.Object , any interface {}) (idx int ) {
26
+ return obj .Call ("unshift" , any ).Int ()
27
+ }
28
+
29
+ //Remove in the front of the array
30
+ func Shift (obj * js.Object ) (idx int ) {
31
+ return obj .Call ("shift" ).Int ()
32
+ }
33
+
34
+ //array slice operation
35
+ // index required,position to add to(remove from),negative means reverse
36
+ // howmany required,number of items to remove, 0 means no remove
37
+ // items... optional,add new items to the array
38
+ func Splice (obj * js.Object , index , howmany int , items ... interface {}) * js.Object {
39
+ args := []interface {}{index , howmany }
40
+ args = append (args , items ... )
41
+ return obj .Call ("splice" , args ... )
42
+ }
20
43
21
- /////// VueJS wrapped Array Operations
22
- /////// in fact normal gopherjs slice ops would effect
23
- /////// the save way
24
- // Add in the bottom of the array
25
- Push func (any interface {}) (idx int ) `js:"push"`
26
- // Remove in the bottom of the array
27
- Pop func () (idx int ) `js:"pop"`
28
- //Add in the front of the array
29
- Unshift func (any interface {}) (idx int ) `js:"unshift"`
30
- //Remove in the front of the array
31
- Shift func () (idx int ) `js:"shift"`
32
- //array slice operation
33
- // index required,position to add to(remove from),negative means reverse
34
- // howmany required,number of items to remove, 0 means no remove
35
- // items... optional,add new items to the array
36
- Splice func (index , howmany int , items ... interface {}) * js.Object `js:"splice"`
37
- Sort func (sorter func (a , b * js.Object ) int ) * js.Object `js:"sort"`
38
- Reverse func () * js.Object `js:"reverse"`
44
+ func Sort (obj * js.Object , sorter func (a , b * js.Object ) int ) * js.Object {
45
+ return obj .Call ("sort" , sorter )
46
+ }
47
+
48
+ func Reverse (obj * js.Object ) * js.Object {
49
+ return obj .Call ("reverse" )
39
50
}
40
51
41
52
// type Vue represents the JavaScript side VueJS instance or VueJS component
@@ -135,13 +146,6 @@ type ViewModel struct {
135
146
// vm.$eval('msg | uppercase') // -> 'HELLO'
136
147
Eval func (expression string ) * js.Object `js:"$eval"`
137
148
138
- // vm.$get( expression )
139
- // expression String
140
- // Retrieve a value from the Vue instance given an expression.
141
- // Expressions that throw errors will be suppressed
142
- // and return undefined.
143
- Get func (expression string ) * Value `js:"$get"`
144
-
145
149
// vm.$set( keypath, value )
146
150
// keypath String
147
151
// value *
0 commit comments