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

Allow using custom types in load #11770

Closed
marcuslimdw opened this issue Jan 31, 2024 · 1 comment
Closed

Allow using custom types in load #11770

marcuslimdw opened this issue Jan 31, 2024 · 1 comment

Comments

@marcuslimdw
Copy link

Describe the problem

Custom types cannot be used in load. This is not a limitation of devalue (which exposes a way to pass reducers/revivers, or functions that allow serde of custom types); it's just that this option is not exposed in SvelteKit.

My specific usecase is fetching data from an external API in load. This API returns, among other things, ISO date strings which I'd like to validate and enrich using luxon. If I could do this, then all throughout the rest of my app I can be sure that my dates are valid luxon.DateTime objects, which makes using and manipulating them a lot easier. Currently, my workflow is something like this:

  1. Get data containing ISO date strings from API
  2. Validate using luxon
  3. Add timezones/change times using luxon
  4. Serialise back to ISO date strings
  5. Return from load
  6. ...
  7. Parse using luxon again
  8. Use

Having this feature would simplify the above to:

  1. Get data containing ISO date strings from API
  2. Validate using luxon
  3. Add timezones/change times using luxon
  4. Return from load
  5. ...
  6. Use

Describe the proposed solution

  • Provide top-level APIs to register reducers and revivers for types, storing them in a global map
  • Pass this map to SvelteKit's internal uses of devalue so that they can be used for serde of custom types

Alternatives considered

No response

Importance

would make my life easier

Additional Information

No response

@Conduitry
Copy link
Member

Duplicate of #9401.

@Conduitry Conduitry closed this as not planned Won't fix, can't repro, duplicate, stale Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants