Skip to content

Event effect returns cause initial event to be reduced after resulting event in event log reducer #4852

Closed
@maaalv

Description

@maaalv

Which @ngrx/* package(s) are the source of the bug?

signals

Minimal reproduction of the bug/regression with instructions

Implementing a meta reducer that should save all events dispatched in the correct order i found that when an effect returns an event the returned event is reduced before the initial event even when the initial event led to the effect.

Here is the exact example:
https://stackblitz.com/edit/github-pqcxwz8j?file=src%2Fevent.store.ts

Clicking the "Emit first event" button does not log the "first" event first but the "second" event, which is the returned one.

Is this expected to work like that? I would expect the "first" event to be reduced first and the returned "second" event in the effect to reduced right after. Addding observeOn(asyncScheduler) into the pipe of the effect fixes it, but it is not clean since it would be needed by any effect. You can also see the line in the example.

Expected behavior

I expect that dispatched events that getting listened by some kind of meta reducers are always getting reduced in the correct order. Events returned from an effect should be reduced after the initial event has been reduced already.

Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)

@ngrx/signals version 19.2.1

Other information

No response

I would be willing to submit a PR to fix this issue

  • Yes
  • No

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions