Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parse and serializer options for persistState #23

Open
ianvink opened this issue Feb 8, 2021 · 3 comments
Open

Add parse and serializer options for persistState #23

ianvink opened this issue Feb 8, 2021 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ianvink
Copy link

ianvink commented Feb 8, 2021

This is a really helpful tool, thank you.

I use Kendo to handle date pickers and Kendo expects a Date() object for FormControl values:

this.mainForm = this.fb.group({
  searchEndDate: [new Date(), Validators.required],
});

With the above, I get a Date() that Kendo consumes.

When I connect the Forms Manager,

 this.formsManager.upsert(this.formManagerKey, this.mainForm, {
   persistState: true
  });

Now 'searchEndDate' is a string

When I add the forms Manager, the date gets converted to a string. Is there a way to get the Forms Manager to maintain the type of the date as a Date()?

@NetanelBasal
Copy link
Member

No. You can't save a Date in localstorage.

@ianvink
Copy link
Author

ianvink commented Feb 9, 2021

Hi,

Is there a way to add a custom deserializer JSON.parse() ? in there I can add a Revive function to convert the date string to a date?

This is such a wonderful project you have made, thank you for your kind efforts and work on it.

Ian

@NetanelBasal
Copy link
Member

You're welcome to submit a PR.

@NetanelBasal NetanelBasal changed the title Dates get converted to string Add parse and serializer options for persistState Feb 10, 2021
@NetanelBasal NetanelBasal added enhancement New feature or request good first issue Good for newcomers labels Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants