How to dispatch an action in NgRx Store DevTools with NgRx 8?
Asked Answered
P

1

5

I've updated my ngrx code to version 8 (with Action Creators etc.), but I don't know now how to use Dispatcher within NgRx Store DevTools.

Before I was able to dispatch actions like this:

{
    type: '[Something] something loaded',
    payload: {
        results: ['a', 'b', 'c']
    }
}

Ngrx Store DevTools dispatcher

Paleolith answered 8/8, 2019 at 11:39 Comment(0)
G
7

In my simple app I have the following Action:

export const SaveUserInfo = createAction(
    '[User] Save user info',
    props<{ user: IUser}>()
);

and the IUser model

export interface IUser {
    name: string;
    money: number;
}

Than in DevTools I dispatch like this:

{
  user: {
    name: 'coiso',
    money: 1000
  },
  type: '[User] Save user info'
}

Hope it works for you.

Genoese answered 8/8, 2019 at 14:55 Comment(2)
Thanks, Paulo. I'm sure I tried this and didn't work. I have just tried again and it has worked. 👍Paleolith
Check the browser console. Once an invalid action is diapatched it produces an exception and after that dispatch from Redux Devtools doesn't work anymore. Otherwise just copy an action from "Raw" view and copy it into the dispatch input to have working examples.Rupee

© 2022 - 2024 — McMap. All rights reserved.