NGRX 7.x Upgrade

#62 · open · 2 comments

View on GitHub ↗

mkay-sh

Version 7.x of the ngrx plattform is out. And this package needs an update. I can provide a pull request for the update if you want.

Comments

kmiskiewicz

I made a fork and published the package https://www.npmjs.com/package/ngrx-typed-actions I also added a new ActionsService which allows to dispatch actions with extra information about the component which triggered the action. This helps a lot when you use the same action in multiple places and have to debug from where the action has been triggered. Let's say that we trigger an action from a HeaderComponent, in the Redux DevTools we will see "\[HeaderComponent\] MyAction". Of course you can still dispatch actions in a standard way, this is only an option if you need more debug information. This looks like: ` // just import the ActionsService private actionsService: ActionsService, // sample action declaration export class MyAction { readonly type = 'MyAction'; constructor(public payload: MyObj) {} } // let's say we trigger the action from e.g. HeaderComponent, // in the Redux DevTools you will see: // [HeaderComponent] MyAction this.actionsService.dispatch(this, MyAction, payload); ` I also added debug information to effects, to use it, just add at the end of the pipe: debugTypeMap('name$'): ` @Effect() Load$ = this.update$.pipe( ofAction(Load), switchMap(() => this.myService.getAll()), map(res => new LoadSuccess(res)), debugTypeMap('Load$'), ); `

denniskuligin

@kmiskiewicz doesn't work with NG8. ofAction, Store class doesn't work correctly.