Skip to content

feat(Effects): Add root effects init action#473

Merged
MikeRyanDev merged 5 commits into
ngrx:masterfrom
timdeschryver:pr/root-effects-init
Oct 13, 2017
Merged

feat(Effects): Add root effects init action#473
MikeRyanDev merged 5 commits into
ngrx:masterfrom
timdeschryver:pr/root-effects-init

Conversation

@timdeschryver

Copy link
Copy Markdown
Member

Closes #246

@coveralls

Copy link
Copy Markdown

Coverage Status

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

@Optional() storeModule: StoreModule
) {
runner.start();
store.dispatch({ type: ROOT_EFFECTS_INIT });

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 { 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown
Member

Thanks @tdeschryver!

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

felikf commented Nov 13, 2017

Copy link
Copy Markdown

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.

5 participants