Dynalon / reactive-state

Redux-clone build with strict typing and RxJS down to its core. Wrist-friendly, no boilerplate or endless switch statements
MIT License
138 stars 7 forks source link

Skip/Jump feature in devtools not working #13

Open Ronsku opened 6 years ago

Ronsku commented 6 years ago

Hi,

Hope everything is good with you and thank you again for keeping updating reactive-state!

I wanted to check with you for a possible bug with reactive-state. I created the most simple demo project I could for you to demonstrate the issue.

https://github.com/Ronsku/reactive-state-issue

The project handles a "start/stop" and switched between states "Idle/inProgress/completed". That's it!

The weird behaviour happens when the store get's messed up by the values for some reason. What I'm expecting is following result:

screen shot 2018-04-21 at 2 02 57

What I get is:

screen shot 2018-04-21 at 2 08 08

And in the redux dev tools you can see that some weird stuff happens. Stop action changes the State value. Stop should not even be running there first of all, but it somehow keeps the old value in the state s-variable and that's why it updates it to an old state, but why?

screen shot 2018-04-21 at 1 44 58

To ge the expected result I can change the actions for setState and start and destroy the immutable system, like in the following code. These changes should be made in reducer.ts.

slice.addReducer(actions.setState, (s, state): State => {
    s.state = state;
    return s;
});
slice.addReducer(actions.start, (s): State => {
    s.status.started = true;
    return s;
});

Even though you do these changes you still have something weird going on in your store, since in redux dev tools you have following results, even though you end on idle-state like you should.

screen shot 2018-04-21 at 2 03 52

I really hope it's my coding mistake, but I cannot really figure out why reactive-state is acting so weird here. I've never had any issues with it before but in this case it seems almost impossible to resolve and it's such straight forward thing that it does. I would be really grateful if you could take a look at the code and the issues and maybe it could even bring out an issue in reactive-state?

If you want/need more information and want to talk to me directly, please send me an email and I will get you a Discord, Skype or any direct messaging invite.

Thank you Timo so much in advance, I really appreciate your help!

Dynalon commented 6 years ago

Hi Ronsku,

thanks for you effort and the detailed code & issue descriptions! I looked at your code, and yes its a bug in reactive-state. More precisely, it is a bug in the devtools. If you uncomment the enableDevTools() line, your code should work as you intended, i guess.

The problem arises from the two-way sync I do between redux and reactive-state in order to get the jump/skip feature working. For now, I have disabled two way sync until I find the issue here. I have released and published version 1.0.1. You can use the devtools with that version (but no jump/skip), please let me know if that fixes your issue. Feel free to hit me up with any other issues you encounter, as your feedback is highly appreciated.

Ronsku commented 6 years ago

Sweet! Thank you so much for your fast response and super quick resolve of the issue and even patched it, amazing! It was so confusing, but it all makes sense now. I was just looking in the wrong place.. 🙂

Everything works exactly as expected now and I will close the issue. Thank you once again!

Dynalon commented 6 years ago

Reopening this as the issue isn't really resolved. I just released a fixed version as I think correctness of code is more important than features in the devtools. But this came at the price of the skip/jump feature in redux devtools.