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(storage-plugin): use state classes as keys #1380

Merged
merged 3 commits into from
Oct 15, 2019

Conversation

arturovt
Copy link
Member

@arturovt arturovt commented Oct 11, 2019

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

Foreword

The key option was very unclear for most of our users. Most people got confused of what the heck is this option and how to use. That's why we had some issues and I made PRs to improve documentation.


This PR scatters cloud and gives our users the ability to provide state classes except of strings. For sure it's still possible to provide strings as this might be a breaking change.


This feature is a good alternative as it's preferred to have state keys only in one place.


It could seem like there is a lot of code added, but no. I moved token factories to the separate internals.ts file, because storage.module.ts file became bigger and bigger. I've only added the transformKeyOption function that retrieves state metadatas from state classes.

So the compiled code is still very small.

Copy link
Member

@splincode splincode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best!!!

@arturovt
Copy link
Member Author

@splincode

Thanks man ❤️

The only thing I don't like is (stateClass as any)[OPTIONS_KEY].name :(

@splincode
Copy link
Member

@markwhitfeld please review it)

Copy link
Member

@markwhitfeld markwhitfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Just a few small cosmetic tweaks.

docs/plugins/storage.md Outdated Show resolved Hide resolved
docs/plugins/storage.md Outdated Show resolved Hide resolved
packages/storage-plugin/src/storage.plugin.ts Show resolved Hide resolved
packages/storage-plugin/src/storage.plugin.ts Outdated Show resolved Hide resolved
@arturovt arturovt merged commit 508734e into master Oct 15, 2019
@arturovt arturovt deleted the feat/state-classes-as-key branch October 15, 2019 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants