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): Add root effects init action #473

Merged
merged 5 commits into from
Oct 13, 2017

Conversation

timdeschryver
Copy link
Member

Closes #246

@coveralls
Copy link

Coverage Status

Coverage increased (+0.9%) to 92.314% when pulling d7cd73d on tdeschryver:pr/root-effects-init into d5640ec on ngrx:master.

@Inject(ROOT_EFFECTS) rootEffects: any[],
@Optional() storeModule: StoreModule
) {
runner.start();
store.dispatch({ type: 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.

I think this needs to be beneath the lines where you add the effects.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed.
Why exactly 😄 ?

Copy link
Member

Choose a reason for hiding this comment

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

Dispatching and registering the effects happens synchronously. Moving the dispatch to after registering the effects will give the effects a chance to listen for this new action type.

import { EffectsRunner } from './effects_runner';
import { EffectSources } from './effect_sources';
import { ROOT_EFFECTS } from './tokens';

export const ROOT_EFFECTS_INIT = '@ngrx/store/root effects init' as '@ngrx/store/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.

I would rename the type string to @ngrx/effects/init

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep you're right, don't know what I was thinking!

@coveralls
Copy link

Coverage Status

Coverage increased (+0.9%) to 92.314% when pulling a8c1419 on tdeschryver:pr/root-effects-init into d5640ec on ngrx:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.9%) to 92.314% when pulling 567d67a on tdeschryver:pr/root-effects-init into d5640ec on ngrx:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.9%) to 92.314% when pulling 567d67a on tdeschryver:pr/root-effects-init into d5640ec on ngrx:master.

@MikeRyanDev MikeRyanDev merged commit 838ba17 into ngrx:master Oct 13, 2017
@MikeRyanDev
Copy link
Member

Thanks @tdeschryver!

@timdeschryver timdeschryver deleted the pr/root-effects-init branch October 13, 2017 16:44
@felikf
Copy link

felikf commented Nov 13, 2017

I am just wondering ... is this supposed to work in feature effects (EffectsModule.forFeature([Effects])? Because it does not...

If I use:

@Effect({ dispatch: false }) init$= this.actions$
    .ofType(ROOT_EFFECTS_INIT)
    .do(console.log.bind(console, 'HIT!!!!'));

in root module, it works (it logs).

When I use it in feature module, it does not (it does not log).

I would need this for feature module though... :)

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.

None yet

5 participants