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

feat: add custom transform functions for state persistence #50

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

VldMrgnn
Copy link
Collaborator

@VldMrgnn VldMrgnn commented Oct 2, 2024

In this refactored version, of PR #45 , I've addressed the feedback by simplifying the API, removing the dynamic setters (setInTransformer and setOutTransformer) to reduce complexity.
The current version still offers flexibility by allowing state transformations without requiring dynamic changes after creation.

If further simplifications are necessary, I'm happy to refactor.

Refactor Highlights:

  • Added support for transform functions to modify the state before storing and after retrieving it from storage.
  • Implemented inbound and outbound transformers for state transformations.
  • Properly handled and logged errors thrown by transformers.
  • Used the transformed state for reconciling and persisting the store.
  • Updated persistStoreMdw to use the transformed state when saving to storage.
  • Added tests to verify the functionality of the persist transformers.

Refactor persist.ts to improve code organization and readability.
- Add support for transform functions to modify the state before storing and after retrieving from storage.
- Implement inbound and outbound transformers to handle state transformations.
- Handle errors thrown by transformers and log them to the console.
- Use the transformed state when reconciling and persisting the store.
- Update persistStoreMdw function to use the transformed state when saving to storage.
- Add tests for persist transformers
@neurosnap neurosnap merged commit fbe29cb into neurosnap:main Oct 3, 2024
3 of 4 checks passed
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

Successfully merging this pull request may close these issues.

2 participants