-
Notifications
You must be signed in to change notification settings - Fork 405
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): allow providing feature states #1994
Conversation
Very interesting work going on here! 🎉 |
bf03709
to
e0f96a2
Compare
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 4d8ac9a. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 3 targetsSent with 💌 from NxCloud. |
e0f96a2
to
a33b2f5
Compare
BundleMon (Integration Projects)Files updated (2)
Total files change +187B +0.14% Final result: ✅ View report in BundleMon website ➡️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really awesome feature!
We need a bit more information of what this feature looks like, so could you add a section in the docs about it, or describe it in the PR description, so that what the feature looks like is clear for review.
Is there a linked issue or discussion? This may assist in making the the problem, and proposed solution clearer.
a33b2f5
to
4d8ac9a
Compare
@@ -12,7 +12,7 @@ export interface KeyWithExplicitEngine { | |||
|
|||
/** Determines whether the provided key has the following structure. */ | |||
export function ɵisKeyWithExplicitEngine(key: any): key is KeyWithExplicitEngine { | |||
return key != null && !!key.engine; | |||
return !!key?.engine; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although very succinct, it is difficult to understand this. Adding brackets would help with understanding.
return !!key?.engine; | |
return !!(key?.engine); |
Caveat... if the prettier formatter wants to remove the brackets, then we would have to rather revert to the previous longer form of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return !!key?.engine; | |
return Boolean(key?.engine); |
NgxsStoragePluginModule.forRoot({ | ||
key: [CounterState] | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to test the case where the root plugin has been initialised with no keys present (therefore every state is stored), and then the blog
route is loaded, which will set a key and engine. Will the existing states be stored? I'm not sure if the current logic handles this scenario.
I think the expectation would be that all states would be stored in the default key, and that explicitly specified feature states would be stored separately.
Maybe we need to discuss what would happen for any other feature states... What is the current behaviour for lazy feature states?
|
||
@Injectable({ providedIn: 'root' }) | ||
export class ɵNgxsStoragePluginKeysManager { | ||
readonly keysWithEngines: KeyWithEngine[] = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exposing this breaks encapsulation. We need to discuss alternatives to exposing this property.
4d8ac9a
to
c24ee47
Compare
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 046d028. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 4 targetsSent with 💌 from NxCloud. |
dc7dfd0
to
589d87b
Compare
This commit introduces the ability to specify states for persistence at the feature level. Previously, you could only specify a list of states for persistence when providing the storage plugin at the root level. This feature is only available with the standalone API, as Angular has an `ENVIRONMENT_INITIALIZER` feature that allows us to add these states at the feature level. The API is simple and straightforward. It introduces the `withStorageFeature` function, which can be called along with `provideStates`. It requires a list of states to be provided. If all states are already being persisted because the developer specified `keys: *` at the root level, this won't do anything.
033e7c8
to
046d028
Compare
Code Climate has analyzed commit 046d028 and detected 1 issue on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 98.1% (50% is the threshold). This pull request will bring the total coverage in the repository to 95.5% (0.0% change). View more on Code Climate. |
Please, add some documentation around this |
And does this method support the |
Issue: #850
This commit introduces the ability to specify states for persistence at the feature level.
Previously, you could only specify a list of states for persistence when providing the storage
plugin at the root level. This feature is only available with the standalone API, as Angular has
an
ENVIRONMENT_INITIALIZER
feature that allows us to add these states at the feature level.The API is simple and straightforward. It introduces the
withStorageFeature
function, whichcan be called along with
provideStates
. It requires a list of states to be provided. If allstates are already being persisted because the developer specified
keys: *
at the root level,this won't do anything.