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(Effects): dispatch init feature effects action on init #1305

Merged
merged 4 commits into from
Aug 31, 2018

Conversation

timdeschryver
Copy link
Member

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: #683

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

If we agree on the API, I'll also add these changes to the docs.
I also would want to change the root effects action name (this will be a breaking change) to make it more clear that it's initiated by the root effects: from @ngrx/effects/init to @ngrx/root-effects/init .

Closes #683

import { getSourceForInstance } from './effects_metadata';

export const FEATURE_EFFECTS_INIT = '@ngrx/feature-effects/init';
export type FeatureEffectsInit = {
Copy link
Member Author

Choose a reason for hiding this comment

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

The reason why I created this is to be typesafe, see the effects test case for a "demo".

@timdeschryver timdeschryver force-pushed the pr/feature-effects-init branch from 99f391c to 0e4cdd2 Compare August 28, 2018 18:02
@coveralls
Copy link

coveralls commented Aug 28, 2018

Coverage Status

Coverage increased (+0.006%) to 88.761% when pulling 0059e01 on timdeschryver:pr/feature-effects-init into fa21f29 on ngrx:master.

import { EffectsRootModule } from './effects_root_module';
import { FEATURE_EFFECTS } from './tokens';
import { getSourceForInstance } from './effects_metadata';

export const FEATURE_EFFECTS_INIT = '@ngrx/feature-effects/init';
Copy link
Member

Choose a reason for hiding this comment

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

I think the prefix should remain @ngrx/effects/something. What about @ngrx/effects/(update-effects or update)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea you're right.
My vote goes for @ngrx/effects/update-effects to keep things consistent with @ngrx/store/update-reducers.

Plus we wouldn't need to change the root effects:

I also would want to change the root effects action name (this will be a breaking change) to make it more clear that it's initiated by the root effects: from @ngrx/effects/init to @ngrx/root-effects/init

Copy link
Member

Choose a reason for hiding this comment

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

👍

@timdeschryver timdeschryver force-pushed the pr/feature-effects-init branch 3 times, most recently from d17dac7 to 68f88c7 Compare August 30, 2018 06:56
@timdeschryver timdeschryver force-pushed the pr/feature-effects-init branch from 68f88c7 to 90ca432 Compare August 30, 2018 07:45
modules/effects/src/effects_feature_module.ts Outdated Show resolved Hide resolved
docs/effects/api.md Outdated Show resolved Hide resolved
### UPDATE_EFFECTS

After feature effects have been registered, a `UPDATE_EFFECTS` action will be dispatched.
This action will have all registered effects as its payload.
Copy link
Member

Choose a reason for hiding this comment

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

action has all newly

Copy link
Member Author

Choose a reason for hiding this comment

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

Just to be sure, you mean that this can be removed right?

Copy link
Member

Choose a reason for hiding this comment

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

No, just update. This action has all newly registered effects as its payload.

docs/effects/api.md Outdated Show resolved Hide resolved
docs/effects/api.md Outdated Show resolved Hide resolved
docs/effects/api.md Outdated Show resolved Hide resolved
@brandonroberts brandonroberts merged commit 15a4b58 into ngrx:master Aug 31, 2018
@timdeschryver timdeschryver deleted the pr/feature-effects-init branch August 31, 2018 13:41
@ThomasBurleson
Copy link
Contributor

Nice. Just what i needed.

@timdeschryver
Copy link
Member Author

Keep in mind this isn't released yet @ThomasBurleson - if you need it now you can install from the nightly builds.

timdeschryver added a commit that referenced this pull request Dec 13, 2018
During a prod build the contructor name of an effect gets magnled,
therefore this implementation can't be used.
brandonroberts pushed a commit that referenced this pull request Dec 20, 2018
During a prod build the contructor name of an effect gets magnled,
therefore this implementation can't be used.
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.

Dispatch action on registration of feature effects
4 participants