zalmoxisus / remotedev

Remote debugging for any flux architecture.
MIT License
145 stars 12 forks source link

Should changes.state be parsed? #5

Closed rob3c closed 7 years ago

rob3c commented 7 years ago

Hi, as I mentioned in the previous issue https://github.com/zalmoxisus/remotedev/issues/4 I just created, I created a custom proxy for using remotedev with @ngrx/store via @ngrx/store-devtools.

I'm not a React/Redux expert and am unsure of what the expected format is, but I noticed that changes.state is a JSON string instead of an object in the subscribe callback. Currently, in my attempt to get time-travel debugging working, I'm calling changes.state = JSON.parse(changes.state) in my wrapper before passing it to the ngrx store devtools. Is this a bug in remotedev, or should the store devtools be parsing it on their end?

Thanks in advance!

zalmoxisus commented 7 years ago

Yes, parsing the state is an expensive operation, so you should call it on your side. However, there's a helper extractState(changes) you can call. It uses jsan.parse under the hood, which, unlike JSON.parse, handles also circular references.

rob3c commented 7 years ago

Thanks - good to know!