kviewmodel--mpp icon indicating copy to clipboard operation
kviewmodel--mpp copied to clipboard

Add sync baseStore

Open evgenru opened this issue 2 years ago • 1 comments

Adds synchronous event handling. This helps to avoid inconsistent data when 2 events arrive at the same time. This makes the store part of functional programming.

To implement your store, you need:

  1. declare your events and states
  2. override the behavior of the reduce method, which acts as a function: newState = f ( event, oldState )

evgenru avatar May 02 '23 03:05 evgenru

Hello. Thanks for PR. This is a rather unusual problem when events come from different threads and there is a need for them to be processed synchronously. In my practice this was not necessary. In general, it's recommended to design viewmodel so that events do not depend on each other and there is no need for sequential processing.

I don't think it should be part of the library. You can always inherit from BaseSharedViewModel and add the desired implementation of obtainEvent

Skeptick avatar May 02 '23 07:05 Skeptick