beedle
beedle copied to clipboard
Add console monitor and use state.message as array.
Possible issue with example demo/basic
Hi, studied your CssTricks tutorial as well as your beedle very carefully and for days now, and learned a lot - Thank you very much !!
However, maybe I found a possible issue with beedle.js.
To "show you some code" I forked beedle and added the deputy branch where a git diff will instantly show you what otherwise could be a thousand words.
A brief summary of what the changes do
<-- Mention how they improve the library and how that happens -->
- In beedle.js : Re-introduce the console.group monitoring from CSS-TRICKS tutorial.
- This shows for demo/basic that setMessage is called TWICE for each action-dispatch
- First while still in resting state
- Second, while in commit method , i. e. , in mutation state.
- You'll get appropriate warnings in the re-introduced console.group for the action.
- Turns out, this stems from directly modifying state.message = 'blah' in the mutation.
- This can be mitigated using state.message[0] = 'blah' (now as an array) inside the mutation.
Thank you very much, Regards, M.
Hi! Thanks very much for putting forward a PR.
Here's some feedback.
-
The console logging was only in the article and was removed for this proper library because it wasn't useful enough to warrant polluting the console. See #6. The aim is to having something more like Redux in the long term.
-
You might have to explain the reasoning as to why you're setting the message as a single array item in the demo. Bear in mind, #20 has a fix for multiple state changes.
Again, thank for you putting in the time to add to Beedle.
Thanks for your response and your time. I'll try to clarify. Wasn't meant as a real PR, however ...
- Take your original beedle code and your demo/basic example.
- Re-introduce temporarily your console monitoring form the article.
- Run demo/basic and type something into the textarea
- You'll get a slew of console.logs showing double-action for each key stroke. That's an error.
- Why there and not in demo/advanced?
- The transition message -> message[0] shows where the problem lies
Do you see what I mean? -- Liked beedle very much, thus my commitment.
Regards, Micha
I think the issue will now have been solved with #20. I’ll just need to manually update the demos now 👍