store-devtools icon indicating copy to clipboard operation
store-devtools copied to clipboard

Serializing ES6 Sets

Open moniuch opened this issue 7 years ago • 2 comments

Please provide me with instructions on how to pass the {serialize: true} parameter to allow ES6 Sets to be seen in store-devtools

https://github.com/zalmoxisus/redux-devtools-extension/issues/378

The following won't even compile due to mistyping:

StoreDevtoolsModule.instrumentOnlyWithExtension({
  serialize: true,
}),

moniuch avatar Jun 28 '17 18:06 moniuch

Similar to #64. Not serializing Map.

juanlizarazo avatar Jul 12 '17 17:07 juanlizarazo

@moniuch

I run into this as well.

The new redux devtools extension from version v2.14.0 and up has support for that { serialize: true }. Unfortunately, @ngrx/store-devtools doesn't support that just yet.

So, my work around in the meantime for nice development experience is to add the .toJSON method to the Map prototype which works great and I can see my maps in state in redux dev tools.

if (environment.envName === 'dev') {
  (Map.prototype as any).toJSON = function () {
    return JSON.parse(JSON.stringify([...this]));
  };
}

Apply same workaround to your Set prototype.

juanlizarazo avatar Jul 12 '17 20:07 juanlizarazo