Effect CommunityEC
Effect Community3y ago
6 replies
canastro

Using Effect.iterate as an alternative to ReadonlyArray.reduce for effects

I have this code:

pipe(events, ReadonlyArray.reduce(initialValue, computeProjection));


but now I changed the computeProjection to now return a Effect Effect.Effect<never, InvalidEventOrderException, P> and therefore I can no longer use ReadonlyArray.reduce.

I was looking into using Effect.iterate (or Effect.forEach + a Ref to keep statee) to achieve this, but not sure if its the most adequate way to do it. Is there any reduce-like API for effects?
Was this page helpful?