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

Effects execution order not guaranteed #64

Open
jmeinlschmidt opened this issue Jul 23, 2023 · 3 comments
Open

Effects execution order not guaranteed #64

jmeinlschmidt opened this issue Jul 23, 2023 · 3 comments

Comments

@jmeinlschmidt
Copy link

Which @ngneat/effects-* package(s) are the source of the bug?

effects, effects-ng

Is this a regression?

No

Description

Please see the complete example at Stackblitz.

Although the effects execution order should be intuitively dependent on the execution order of actions, in reality, it depends on the effects declaration order.

The example provided in the Stackblitz prints SECOND followed by FIRST, even though it should be the other way. In order to fix this behaviour, it is necessary to change the effects declaration order (moving the load effect at the end). This can introduce some serious bugs which are hard to explore.

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-heh5qh?devToolsHeight=33&file=src%2Ftodo.effects.ts

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in

No response

Anything else?

In my opinion, this should be mentioned in the docs, at least.

Do you want to create a pull request?

No

@stackblitz
Copy link

stackblitz bot commented Jul 23, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@EricPoul
Copy link
Collaborator

EricPoul commented Jul 25, 2023

Hi. I looked at your example and it works fine.
of()(in the TodoService) is synchronous, and since its effect is declared first it also prints first. that's not a problem with effects, it's how rxjs works.

Here's an example in clear rxjs https://stackblitz.com/edit/rxjs-bmjf66?devtoolsheight=60&file=index.ts

@EricPoul
Copy link
Collaborator

there's a doc in the elf/store. It's a little different but still about the same how rxjs works
https://ngneat.github.io/elf/docs/troubleshooting/stale-emission

You can add auditTime(0) to fix the problem.

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

No branches or pull requests

2 participants