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(store): expose StateContextFactory, StateFactory #1325

Merged
merged 6 commits into from
Oct 2, 2019

Conversation

splincode
Copy link
Member

@splincode splincode commented Sep 14, 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: #1323

What is the new behavior?

For the plugin @ngxs-labs/data needs a more api from @ngxs/store. Because @ngxs-labs/data use deep internal manipulation with Store.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

For the plugin `@ngxs-labs/data` needs a more api from `@ngxs/store`.
Because `@ngxs-labs/data` use deep internal manipulation with Store.
@splincode
Copy link
Member Author

splincode commented Sep 24, 2019

@markwhitfeld Please, I need this functionality in production right now. Therefore, I want to use this functionality in our projects.

Now I can’t wait, so on production I will use

{
  "@ngxs/store": "3.5.1@dev",
  "@ngxs-labs/data": "1.0.1"
}

This functionality is really necessary for the plugin.

@splincode
Copy link
Member Author

splincode commented Sep 24, 2019

One of the big problems is that ngcc generates randomly ɵm, ɵp, ɵt, ...

image

Therefore, the plugin does not work @ngxs-labs/data

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.

@splincode As mentioned on the reported issue (#1323) I really do not want to expose the internals of NGXS for plugins. This can compromise the fundamentals of the framework and cause instability in the plugins if we change these internals at a later stage.

The only option that I would accept here is to expose these from the @ngxs/store/internals subpackage. The way I can see to achieve this would be to expose an InjectionToken that will be used for each of these from the internals subpackage. Then those InjectionTokens would be used to provide those classes to the injector within the main @ngxs/store package. In this way these classes will remain in the main package but are accessible to anyone that wants to risk referencing something from the @ngxs/store/internals subpackage. You could expose TS type definitions for these from the internals subpackage too if you like, but not the underlying classes (these should remain in the main package).
(remember that the internals subpackage can receive breaking changes without affecting the semantic versioning)

This the best that I can offer.

@splincode
Copy link
Member Author

@markwhitfeld updated

image

packages/store/src/module.ts Outdated Show resolved Hide resolved
packages/store/src/module.ts Outdated Show resolved Hide resolved
packages/store/internals/src/internal-tokens.ts Outdated Show resolved Hide resolved
packages/store/internals/src/internal-tokens.ts Outdated Show resolved Hide resolved
@splincode
Copy link
Member Author

@markwhitfeld done

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.

Great!
PS. I'm not sure what the conventions are for naming tokens. I assumed that the _TOKEN suffix is the convention based on what already existed in the file.
@arturovt could you review again?

Copy link
Member

@arturovt arturovt left a comment

Choose a reason for hiding this comment

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

I'm pre-approving that.

So after our comments you're free to merge this 😉

packages/store/internals/src/internal-tokens.ts Outdated Show resolved Hide resolved
packages/store/internals/src/internal-tokens.ts Outdated Show resolved Hide resolved
packages/store/internals/src/internal-tokens.ts Outdated Show resolved Hide resolved
@splincode
Copy link
Member Author

image

  • updated
  • removed link operator

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.

Great!

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.

Ah man, I see the failing tests for NG5.
It would be ideal to use unknown but it is a new TypeScript feature, so we will have to go with any.
image

@arturovt
Copy link
Member

arturovt commented Oct 2, 2019

Sure, I’m ok with that.

Copy link
Member

@arturovt arturovt left a comment

Choose a reason for hiding this comment

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

Guess we have to drop the support for ng5 as it's like to support mammoths 😁

@splincode
Copy link
Member Author

@arturovt only in V4

@splincode splincode merged commit ea5e70f into master Oct 2, 2019
@splincode splincode deleted the feat/ngxs-data branch October 2, 2019 19:17
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.

3 participants