-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Vuex action dispatch display? #179
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
Comments
Why would you need to display actions? What affects your store are mutations. I think actions would bloat up the view for no real interest |
I think that this would be a useful feature. Most of my complex logic happens inside of actions. Each of my mutations is very simple and could be have been dispatched from one of many actions. Viewing mutations is too granular for efficient debugging sometimes. |
You wouldn't be able to time travel actions anyway |
What would be very useful is if it would be possible to display what actions caused which mutations. Even if it is not possible to do that accurately, just logging out the actions that occurred can help with reasoning about what caused what. The benefit of uni directional action dispatch is reasoning about data flow. Showing this in log / debug tool is exactly what it should be used for. |
I've been working around this by putting |
Would there be other scenarios where it could be useful to pass the action name as an optional parameter of the commit function? I so, I believe a parameter like that could be used in order to see from what action a mutation gets called. Perhaps one scenario where it could be beneficial to have another parameter to the commit function, named something like "calledBy", "callee" or sligtly more likely "action", would be to make the mutations be aware of in which context they are beeing called, and then slightly more instructed on what to do. However, displaying this in a good way inside Vue devtools seems to be a bit harder indeed, due to the asyncronous nature of actions. Some time format that includes ms might do a job though, in order to know when the action was called, and when the mutation was called. But the question to me, seems to be weather adding another parameter to the commit function adds value or not outside devtools. Sorry about another duplicate issue, btw. I´ll dig deeper next time indeed! 👍 |
@b44d, having an optional parameter will make code complicated and probably not BC. Perhaps we can have an alias commit function in development mode. It will log the the (action, commit) pair and call the real commit. This can be better, if actions can have a unique id to group commits they called. |
@motia I very much agree that cluttering the commit function with another parameter doesn´t sound like the best idea. An alias is definitely be a better alternative here, but very curious on what the core team thinks about this, as it doesn´t look like something I have seen around elsewhere yet. But, what if something like these aliases were added when compiling a development bundle? dispatch__trace(action, payload, calledBy) Both simply forward to the original function, while they in development mode also log to Vue devtools, using a (temporarily named) 'calledBy' parameter. The reason for also adding an alias for dispatch, btw, is to also be able to know from where this action is called. Was this action called from a component, a plugin, or from a lib etc. |
As @sbward mentioned:
Completely agree. IMO even if we can't time travel, having a log of actions/payloads would be really useful to track the whole flow. |
Would also love to see this. |
@b44rd Now that we have the ability to do this, wanna sync and give it a shot? |
Yes! Definetely. I believe we first need to agree on this. Should a action debugging option be a part of the contents inside the Vuex tab, or should it be a seperate tab? @yyx990803, @posva, @deini? I see that there´s valid reasons for both, so it´s more a matter of deciding what´s the more convenient option.
Opinions? |
🤔 Good points, I honestly don't know whats the best approach, it is indeed part of Displaying actions and mutations on the same list might get messy, if I understand this correctly you can't go back in time with actions like you do with mutations. So we would need to have a clean separation. |
Started thinking about the time travel thing. When the action is called, we actually know the current state. So it would actually be possible to time travel to the state as it is before the action is does something. It doesn’t sound like a good idea to actually implement anything time travel related as a part of displaying the actions though, as it might create more confusion than it provides relevance for anything. Especially since this time travel would need to integrate logically with the existing time travel, which behaves slightly different. What would be a nice goal to achieve though, is in my opinion two things.
If the actions has got a seperate tab, it will be a useful usage pattern to first discover/inspect an action, see that a mutation got called, and then start to inspect the mutation. I’d say a seperate tab will be the best starting point here. This will add usefulness for those needing to inspect actions, and it will not complicate the Vuex tab for those who don’t. What do you think? |
Agreed with the above two points. In my opinion, the absolute minimum would be:
Bonus Feature 1. Display in a tree structure the actions/mutations within the action. If an action is called within an action, recurse. The analogy of the tree structure here is that actions are folders and mutations are files. Bonus Feature 2. Display a snapshot of the state after each action and/or after each mutation for extra granularity. Right now, having a list of just mutations flooding my vue-devtools is becoming less and less useful as my applications increases in complexity. Soon I may just start relying on console.log and almost entirely ignoring the vue-devtools until we can track actions. |
@b44rd I think adding this to the timeline would complexify it way too much. I feel that the important information is which actions committed a mutation. This is something that can be added to the right panel when a mutation is selected without bloating the vuex pannel. |
@posva so let it be filterable with a check-box. Coming from redux where devtools do have every action (since it has no distinction between mutations and actions in the first place) I'm very surprised at the absence of this feature. |
I also think it might be a useful feature and would love to see it in action. Btw. I think we'll need a UX guy in order to not bloat devtools in future anyway :D |
With this feature, I can easily find out which action triggers the mutation. Its really important actually |
During development, I often need to step through my application. Having an option to show actions would be very helpful. It doesn't need to be on by default, but the option should be there. |
|
Waiting for this feature too. |
It will be a really useful feature. What kind of problem stops us from implementing it? |
I'm interested in this feature. However, I would prefer to be able to see the call stack that triggered the mutation. |
We will definitely implement this, however it will probably be done in coordination with the next Vuex upgrade, likely later half of the year. |
Within the Redux world, actions are viewable to guarantee developers could look at what's going on, from a higher perspective, on your SPA. |
+1 for this and for call stacks. |
+1 |
+1 |
1 similar comment
+1 |
Unfortunately we entered the later half of the next year and instead of pushing tools like this one and vue-test-utils which is still beta, what is pushed is the react-like-new-Vue3 api. It doesn't make sense. |
Is there any update on that? It gets hard to track when you have actions calling other actions. |
Who cares about time travel? I just want to know what happens. We don't even use mutations unless something outside of the store should be able to set those values. |
This moves the mutation of the statementState to only after successful persistence (and round trip) to the server, allowing us to attempt a retry in the future. Consequently, the originalStatement state became obsolete and could be removed. Detection of changed state (by user input) happens by comparison between targetValue and the contents of statementModule. applyStringDataValue would not need to be an actual store action (maybe it is even somewhat confusing) and it can move out when implementing the different patch strategies. One downside of state update after successful save only: As actions are not tracked in vue dev tools[0], this makes for poor visibility of what is going on - the "mutations" are performed only on a copy of the statements state before submitting the change, which is not visible in the otherwise very helpful browser extension. I'm unsure about the value of the applyStringDataValue integration tests as they don't integrate a lot. [0] vuejs/devtools-v6#179 Bug: T238662 Change-Id: Id0a9f656ee06f15fb814e6ecd724b934c50bf6ad
* Update Wikibase from branch 'master' to 224b59f3e0a01a7a7f9e313ec61098c3d56bc53a - Merge "bridge: put targetValue into statement only on save" - bridge: put targetValue into statement only on save This moves the mutation of the statementState to only after successful persistence (and round trip) to the server, allowing us to attempt a retry in the future. Consequently, the originalStatement state became obsolete and could be removed. Detection of changed state (by user input) happens by comparison between targetValue and the contents of statementModule. applyStringDataValue would not need to be an actual store action (maybe it is even somewhat confusing) and it can move out when implementing the different patch strategies. One downside of state update after successful save only: As actions are not tracked in vue dev tools[0], this makes for poor visibility of what is going on - the "mutations" are performed only on a copy of the statements state before submitting the change, which is not visible in the otherwise very helpful browser extension. I'm unsure about the value of the applyStringDataValue integration tests as they don't integrate a lot. [0] vuejs/devtools-v6#179 Bug: T238662 Change-Id: Id0a9f656ee06f15fb814e6ecd724b934c50bf6ad
Any news about this? |
It would also be pretty useful to be able to dispatch actions right from the devtools for testing purposes. |
Hey guys, I was annoyed by this so I made a package to trace import { mutationLogger, actionLogger } from 'vuex-trace'
const store = new Vuex.Store({
state,
mutations,
plugins: [mutationLogger(), actionLogger()]
}) Have a go and let me know, it's based on vuex's built-in-logger-plugin |
Any updates on this? Not knowing which actions have been dispatched makes debugging a lot harder, since individual mutations could have been committed from a number of different spots in the code. |
@jan-scorl while you wait this could help you... I have added this for debugging and works well.
|
A massive +1, oh how I've never typed "+1" so hard. @andrew-bibby's solution is what I typically do – but my console is bloated enough, it would be great to have this be handled in vue-devtools :) |
Just to promote this issue further: What is the current status on this Issue? What would get this Issue out of "in consideration"? |
Iirc, a plan for vuex 5 is to get rid of the distinction between actions and commits completely. So this feature will arise naturally from that change. |
Is there a plan to log and display dispatched vuex actions in the devtools?
The text was updated successfully, but these errors were encountered: