@@ -19,6 +19,13 @@ export function setupPlugin (api: DevtoolsApi, app: App, Vue) {
19
19
label : 'Vue 2' ,
20
20
homepage : 'https://vuejs.org/' ,
21
21
logo : 'https://vuejs.org/images/icons/favicon-96x96.png' ,
22
+ settings : {
23
+ legacyActions : {
24
+ label : 'Legacy Actions (enable with Vuex < 3.1.0)' ,
25
+ type : 'boolean' ,
26
+ defaultValue : false ,
27
+ } ,
28
+ } ,
22
29
} , api => {
23
30
const hook = target . __VUE_DEVTOOLS_GLOBAL_HOOK__
24
31
@@ -164,55 +171,75 @@ export function setupPlugin (api: DevtoolsApi, app: App, Vue) {
164
171
} )
165
172
} )
166
173
167
- store . subscribeAction ?.( {
168
- before : ( action , state ) => {
169
- const data : any = { }
170
- if ( action . payload ) {
171
- data . payload = action . payload
172
- }
173
- action . _id = actionId ++
174
- action . _time = Date . now ( )
175
- data . state = state
176
-
177
- api . addTimelineEvent ( {
178
- layerId : VUEX_ACTIONS_ID ,
179
- event : {
180
- time : action . _time ,
181
- title : action . type ,
182
- groupId : action . _id ,
183
- subtitle : 'start' ,
184
- data,
185
- } ,
186
- } )
187
- } ,
188
- after : ( action , state ) => {
189
- const data : any = { }
190
- const duration = Date . now ( ) - action . _time
191
- data . duration = {
192
- _custom : {
193
- type : 'duration' ,
194
- display : `${ duration } ms` ,
195
- tooltip : 'Action duration' ,
196
- value : duration ,
174
+ function legacySingleActionSub ( action , state ) {
175
+ const data : any = { }
176
+ if ( action . payload ) {
177
+ data . payload = action . payload
178
+ }
179
+
180
+ data . state = state
181
+
182
+ api . addTimelineEvent ( {
183
+ layerId : VUEX_ACTIONS_ID ,
184
+ event : {
185
+ time : Date . now ( ) ,
186
+ title : action . type ,
187
+ data,
188
+ } ,
189
+ } )
190
+ }
191
+
192
+ store . subscribeAction ?.( api . getSettings ( ) . legacyActions
193
+ ? legacySingleActionSub
194
+ : {
195
+ before : ( action , state ) => {
196
+ const data : any = { }
197
+ if ( action . payload ) {
198
+ data . payload = action . payload
199
+ }
200
+ action . _id = actionId ++
201
+ action . _time = Date . now ( )
202
+ data . state = state
203
+
204
+ api . addTimelineEvent ( {
205
+ layerId : VUEX_ACTIONS_ID ,
206
+ event : {
207
+ time : action . _time ,
208
+ title : action . type ,
209
+ groupId : action . _id ,
210
+ subtitle : 'start' ,
211
+ data,
212
+ } ,
213
+ } )
197
214
} ,
198
- }
199
- if ( action . payload ) {
200
- data . payload = action . payload
201
- }
202
- data . state = state
203
-
204
- api . addTimelineEvent ( {
205
- layerId : VUEX_ACTIONS_ID ,
206
- event : {
207
- time : Date . now ( ) ,
208
- title : action . type ,
209
- groupId : action . _id ,
210
- subtitle : 'end' ,
211
- data,
215
+ after : ( action , state ) => {
216
+ const data : any = { }
217
+ const duration = Date . now ( ) - action . _time
218
+ data . duration = {
219
+ _custom : {
220
+ type : 'duration' ,
221
+ display : `${ duration } ms` ,
222
+ tooltip : 'Action duration' ,
223
+ value : duration ,
224
+ } ,
225
+ }
226
+ if ( action . payload ) {
227
+ data . payload = action . payload
228
+ }
229
+ data . state = state
230
+
231
+ api . addTimelineEvent ( {
232
+ layerId : VUEX_ACTIONS_ID ,
233
+ event : {
234
+ time : Date . now ( ) ,
235
+ title : action . type ,
236
+ groupId : action . _id ,
237
+ subtitle : 'end' ,
238
+ data,
239
+ } ,
240
+ } )
212
241
} ,
213
- } )
214
- } ,
215
- } , { prepend : true } )
242
+ } , { prepend : true } )
216
243
217
244
// Inspect getters on mutations
218
245
api . on . inspectTimelineEvent ( payload => {
0 commit comments