@@ -10,19 +10,19 @@ import (
10
10
type LifeCycleEvent string
11
11
12
12
const (
13
- VmInit LifeCycleEvent = "init"
14
- VmCreated LifeCycleEvent = "created"
15
- VmBeforeCompile LifeCycleEvent = "beforeCompile"
16
- VmCompiled LifeCycleEvent = "compiled"
17
- VmReady LifeCycleEvent = "ready"
18
- VmAttached LifeCycleEvent = "attached"
19
- VmDetached LifeCycleEvent = "detached"
20
- VmBeforeDestroy LifeCycleEvent = "beforeDestroy"
21
- VmDestroyed LifeCycleEvent = "destroyed"
13
+ EvtBeforeCreate LifeCycleEvent = "beforeCreate"
14
+ EvtCreated LifeCycleEvent = "created"
15
+ EvtBeforeMount LifeCycleEvent = "beforeMount"
16
+ EvtMounted LifeCycleEvent = "mounted"
17
+ EvtBeforeUpdate LifeCycleEvent = "beforeUpdate"
18
+ EvtUpdated LifeCycleEvent = "updated"
19
+ EvtActivated LifeCycleEvent = "activated"
20
+ EvtDeactivated LifeCycleEvent = "deactivated"
21
+ EvtBeforeDestroy LifeCycleEvent = "beforeDestroy"
22
+ EvtDestroyed LifeCycleEvent = "destroyed"
22
23
)
23
24
24
- // Option are used to organize mutiple sub component together to
25
- // construct VueJS apps or (higher level) components.
25
+ // Option is used to config VueJS instance or to create VueJS components.
26
26
type Option struct {
27
27
* js.Object
28
28
@@ -139,9 +139,7 @@ type Option struct {
139
139
Parent * js.Object `js:"parent"`
140
140
141
141
// map to sub component
142
- mcom map [string ]* Component
143
- // map to event handler
144
- mevt map [string ]interface {}
142
+ coms map [string ]* Component
145
143
// properties
146
144
props []string
147
145
// mixins
@@ -152,8 +150,7 @@ func NewOption() *Option {
152
150
c := & Option {
153
151
Object : js .Global .Get ("Object" ).New (),
154
152
}
155
- c .mcom = make (map [string ]* Component , 0 )
156
- c .mevt = make (map [string ]interface {}, 0 )
153
+ c .coms = make (map [string ]* Component , 0 )
157
154
c .props = []string {}
158
155
c .mixins = []js.M {}
159
156
return c
@@ -174,11 +171,8 @@ func (o *Option) NewComponent() *Component {
174
171
175
172
// prepare set the proper options into js.Object
176
173
func (c * Option ) prepare () (opts * js.Object ) {
177
- if len (c .mcom ) > 0 {
178
- c .Set ("components" , c .mcom )
179
- }
180
- if len (c .mevt ) > 0 {
181
- c .Set ("events" , c .mevt )
174
+ if len (c .coms ) > 0 {
175
+ c .Set ("components" , c .coms )
182
176
}
183
177
if len (c .props ) > 0 {
184
178
c .Set ("props" , c .props )
@@ -243,17 +237,7 @@ func (c *Option) addMixin(name string, val interface{}) *Option {
243
237
244
238
// AddComponent add sub component to the genereated VueJS instance (optional)
245
239
func (c * Option ) AddSubComponent (name string , sub * Component ) * Option {
246
- c .mcom [name ] = sub
247
- return c
248
- }
249
-
250
- // On add EventHandler to VueJS-generated component-oriented event
251
- // for cross component message passing
252
- func (c * Option ) On (event string , fn func (vm * ViewModel , args []* js.Object )) * Option {
253
- c .mevt [event ] = js .MakeFunc (func (this * js.Object , args []* js.Object ) interface {} {
254
- fn (newViewModel (this ), args )
255
- return nil
256
- })
240
+ c .coms [name ] = sub
257
241
return c
258
242
}
259
243
0 commit comments