Are persist and stash invalid together?

It appears as though I cannot persist and then stash like so:

        return Effect().persist(new SomeEvent())
                .thenRun(s -> Effect().stash());

Is this expected? Returning just the Effect().stash() does work.

You have just persisted an event based on the command so stashing it does not sound right.

Actual explanation to what is going on: .thenRun is for arbitrary side effects, so you could create any Effect there, it will be completely ignored since the function .thenRun() takes is State => Unit.

1 Like