Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action types wrong when subscribing for Action dispatch/success #83

Open
visurel opened this issue Dec 11, 2018 · 0 comments
Open

Action types wrong when subscribing for Action dispatch/success #83

visurel opened this issue Dec 11, 2018 · 0 comments
Labels
bug Something isn't working

Comments

@visurel
Copy link

visurel commented Dec 11, 2018

When listening to actions from import { Actions } from '@ngxs/store' and getting the action type with the import { getActionTypeFromInstance } from '@ngxs/store' and having an interaction with another state in the called @receiver() action, the type returned from getActionTypeFromInstance behaves weird and in some scenarios mixes the types so that there's e.g:

  1. DISPATCHED: [ID: 123]
  2. DISPATCHED: [ID: 999]
  3. SUCCESSFUL: [ID: 999]
  4. SUCCESSFUL: [ID: 999]

Sometimes it's also always just the "ID 999" on all the types.

I'd expect it to be:

  1. DISPATCHED: [ID: 123]
  2. DISPATCHED: [ID: 999]
  3. SUCCESSFUL: [ID: 999]
  4. SUCCESSFUL: [ID: 123]

OR

  1. DISPATCHED: [ID: 123]
  2. SUCCESSFUL: [ID: 123]
  3. DISPATCHED: [ID: 999]
  4. SUCCESSFUL: [ID: 999]

or something similiar. Point is, a dispatched type should also SUCCESSFUL, CANCELED or ERRORED at some time.

I hope I explained this detailed enough. Just for clarification: This issue doesn't happen when using @action(). With @action() everything works as expected. It just happens with @receiver()

When using @receiver() in the first action and inside the first action then using dispatch(new OtherAction(...)) the issue also doesn't appear. Just when both are @receiver().

Here's also a reproduction on Stackblitz (check the console.logs, it only shows "CounterState", while it should show for 2 of the logs "OtherState"): https://stackblitz.com/edit/ngxs-emitter-example-dbv5fp?file=src%2Fapp%2Fstore%2Fother.state.ts

@splincode splincode pinned this issue Jan 9, 2019
@splincode splincode added the bug Something isn't working label Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants