Nicholas Jamieson
1 min readNov 30, 2017

--

reactjs/redux includes a check to ensure that only plain objects can be dispatched. I recall hearing, in a podcast interview, Dan Abramov give his definition of Redux, and that definition included the ability to use time-travel debugging — with the Redux DevTools. So time-travel debugging is a fundamental Redux feature.

Unfortunately, Medium does not appear to allow strikethrough to be used. Pretty much everything beneath this is wrong. Read the response, instead.

With the Redux Chrome DevTools extension, actions are serialized to JSON as part of the communication between the page and the extension. Clearly, if something other than a plain object is serialized and then deserialized, what you end up with is not what you started with. Whether or not this is a problem depends upon what you are expecting.

NgRx does not include a check for plain objects and it’s certainly possible to use actions that are class instances without problems — with the Redux DevTools extension — as long as you are not relying on instanceof or non-serializable properties or methods, you will be fine.

I look at the decision to allow only plain objects in reactjs/redux as a defensive one. If you are limited to only dispatching plain objects, your reducers will always receive what was dispatched. If, however, you are able to dispatch class instances, you might sometimes receive something different to what was dispatched.

The Redux documentation mentions that state should be serializable as JSON.

--

--

Nicholas Jamieson
Nicholas Jamieson

Written by Nicholas Jamieson

RxJS core team member; front-end developer; mentor; speaker; open-source contributor

Responses (1)