ngrx / store-devtools

Developer Tools for @ngrx/store
MIT License
326 stars 38 forks source link

Serializing ES6 Sets #67

Open moniuch opened 7 years ago

moniuch commented 7 years ago

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,
}),
juanlizarazo commented 7 years ago

Similar to #64. Not serializing Map.

juanlizarazo commented 7 years ago

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