According to docs the mapEventToState function must return a new state:
/// Takes the incoming [event] as the argument.
/// [mapEventToState] is called whenever an [event] is [add]ed.
/// [mapEventToState] must convert that [event] into a new [state]
/// and return the new [state] in the form of aStream<State>.
Is it really obligatory to yield a new state per event? What if the event did not change the state for some reason? (should I return a copy of existing state in such case)?
Thank you for this library!
Hi @darek607 👋
I see why that might be confusing, there's probably room for improvement with the description.
Is it really obligatory to yield a new state per event?
You're not forced to yield a new state as a result of an event. You can yield a new state, multiple states or no state at all.
What if the event did not change the state for some reason? (should I return a copy of existing state in such case)?
No, you don't have to yield anything in this case.
Hope that helps ✌
Hi @darek607 👋
Thanks for opening an issue!
As @RollyPeres mentioned, it's not necessary and I've updated the documentation as part of #1698 👍
Thank you guys very much🙇
Most helpful comment
Thank you guys very much🙇