-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix to devtools-plugin to support Actions without a "callback" param #460
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,6 +144,10 @@ export default function devToolsPlugin() { | |
return action(ctx, payload, cb); | ||
} | ||
|
||
function timedActionNoCallback(ctx, payload) { | ||
return timedAction(ctx, payload); | ||
} | ||
|
||
function timedCallback(err, data) { | ||
const endTime = Date.now(); | ||
const dur = endTime - actionReference.startTime; | ||
|
@@ -155,7 +159,7 @@ export default function devToolsPlugin() { | |
|
||
return { | ||
actionContext: actionContext, | ||
action: timedAction, | ||
action: (action.length < 3) ? timedActionNoCallback : timedAction, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actions can also return promises so this might effect those too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. timedAction does a return on the wrapped action, and timedActionNoCallback returns the return value of timedAction, so if a promise is returned it would be returned |
||
payload: options.payload, | ||
done: timedCallback | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to call these two lines before returning
timedAction
Without a start time these actions might not end up in the correct place in the timeline. The payload will also be useful for debugging actions called w/o a callback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call to "timedAction" sets those values already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seemed to show up in the correct place in the timeline for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you're right, I thought you were directly calling the action just w/o a callback.