beedle icon indicating copy to clipboard operation
beedle copied to clipboard

Add console monitor and use state.message as array.

Open christomonte11 opened this issue 5 years ago • 3 comments

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 -->

  1. In beedle.js : Re-introduce the console.group monitoring from CSS-TRICKS tutorial.
  2. 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.
  3. Turns out, this stems from directly modifying state.message = 'blah' in the mutation.
  4. This can be mitigated using state.message[0] = 'blah' (now as an array) inside the mutation.

Thank you very much, Regards, M.

christomonte11 avatar Apr 11 '19 16:04 christomonte11

Hi! Thanks very much for putting forward a PR.

Here's some feedback.

  1. 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.

  2. 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.

Andy-set-studio avatar Apr 15 '19 20:04 Andy-set-studio

Thanks for your response and your time. I'll try to clarify. Wasn't meant as a real PR, however ...

  1. Take your original beedle code and your demo/basic example.
  2. Re-introduce temporarily your console monitoring form the article.
  3. Run demo/basic and type something into the textarea
  4. You'll get a slew of console.logs showing double-action for each key stroke. That's an error.
  5. Why there and not in demo/advanced?
  6. 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

christomonte11 avatar Apr 15 '19 22:04 christomonte11

I think the issue will now have been solved with #20. I’ll just need to manually update the demos now 👍

Andy-set-studio avatar Apr 15 '19 22:04 Andy-set-studio