Skip to content

Commit

Permalink
feat(devtools): add more data to actions
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed May 12, 2021
1 parent 06b72f5 commit e8f4b0e
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/devtools/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ActionsTree,
} from '../types'
import {
formatDisplay,
formatEventData,
formatMutationType,
formatStoreForInspectorState,
Expand Down Expand Up @@ -165,18 +166,27 @@ export function addDevtools(app: App, store: Store) {
event: {
time: Date.now(),
title: '🛫 ' + name,
data: args,
subtitle: 'start',
data: {
action: formatDisplay(name),
args,
},
groupId,
},
})

after(() => {
after((result) => {
api.addTimelineEvent({
layerId: MUTATIONS_LAYER_ID,
event: {
time: Date.now(),
title: '🛬 ' + name,
data: args,
subtitle: 'end',
data: {
action: formatDisplay(name),
args,
result,
},
groupId,
},
})
Expand All @@ -188,8 +198,10 @@ export function addDevtools(app: App, store: Store) {
event: {
time: Date.now(),
logType: 'error',
title: '❌ ' + name,
title: '💥 ' + name,
subtitle: 'end',
data: {
action: formatDisplay(name),
args,
error,
},
Expand Down Expand Up @@ -295,8 +307,11 @@ export function devtoolsPlugin<
}
}

// FIXME: can this be fixed?
addDevtools(app, store as unknown as Store)
addDevtools(
app,
// @ts-expect-error: FIXME: if possible...
store
)

return { ...wrappedActions }
}
Expand Down

0 comments on commit e8f4b0e

Please sign in to comment.