ngrx / store-devtools

Developer Tools for @ngrx/store
MIT License
325 stars 38 forks source link

Events in constructor or ngOnInit not dispatched in RC5 #25

Closed SamVerschueren closed 7 years ago

SamVerschueren commented 8 years ago

@brechtbilliet pointed out that there is a problem when dispatching events in the constructor or in the ngOnInit lifecycle hooks.

The original post can be found here: https://github.com/ngrx/example-app/issues/30#issuecomment-240427149

There is a problem when dispatching initial events (in constructor or ngOnInit) when using the instrumentStore function in the providers property. They will just be ignored. Check this plunk http://plnkr.co/edit/00IJ8KBRXLDPPykFwcyD

in app/app.component.ts these tree lines should add three users:

constructor(private store: Store){

this.store.dispatch({type: "ADD_USER", payload: {user:"user"}});
this.store.dispatch({type: "ADD_USER", payload: {user:"user"}});
this.store.dispatch({type: "ADD_USER", payload: {user:"user"}});

} The users are being added correctly. In app/app.module.ts, uncomment the instrumentStore function and you will the events will not be dispatched anymore. Also uncomment StoreLogMonitorComponent to test

I noticed that dispatching the actions in ngAfterViewInit did work, everything before that lifecycle hook doesn't.

MikeRyanDev commented 8 years ago

I'm 90% through converting this library to be more RC5 compliant. Let's investigate with the next beta.

brechtbilliet commented 8 years ago

Still happening with the 3.0.0 release

montella1507 commented 7 years ago

I hope this will be fixed soon, because it is a big problem for us.. We just can't use it now.

I would like to be able to help you, unfortunately i dont have enough of experience with ngrx..

MikeRyanDev commented 7 years ago

@SamVerschueren @brechtbilliet @montella1507 Do you drop out of the zone using the Redux Devtools extension or just using @ngrx/store-log-monitor?

montella1507 commented 7 years ago

@MikeRyan52 no, the same problem is in Internet explorer too. (without redux extensions).

MikeRyanDev commented 7 years ago

Should be fixed in v3.2.0

montella1507 commented 7 years ago

@MikeRyan52 Thank you very much! Works like a sharm again! We are very appreciated for your great work!