Skip to content
This repository was archived by the owner on Jul 8, 2021. It is now read-only.

NGRX 7.x Upgrade #62

Open
mkay-sh opened this issue Jan 15, 2019 · 2 comments
Open

NGRX 7.x Upgrade #62

mkay-sh opened this issue Jan 15, 2019 · 2 comments

Comments

@mkay-sh
Copy link

mkay-sh commented Jan 15, 2019

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.

@kmiskiewicz
Copy link

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

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants