Store

constructor(reducer: Reducer<S, A>, initialState: S, coroutineDispatcher: CoroutineDispatcher = Dispatchers.Default, coroutineScopeName: String = DEFAULT_COROUTINE_SCOPE_NAME, effectIdSource: EffectIdSource = UUIDEffectIdSource(), logger: Logger = NoopLogger(), exceptionHandler: ExceptionHandler = ThrowingExceptionHandler, parentJob: Job? = null)

Parameters

reducer

The Reducer that will handle Actions and determine state updates and reactions.

initialState

The initial state of the Store.

coroutineDispatcher

The CoroutineDispatcher all operations run on. Reducer, effects, and internal operations run on this dispatcher. Default value is Dispatchers.Default.

coroutineScopeName

The name for the CoroutineScope the Store uses. Useful for debugging. The default is DEFAULT_COROUTINE_SCOPE_NAME.

logger

A logger that logs received actions and state updates. Useful for debugging. The default is NoopLogger.

exceptionHandler

The ExceptionHandler that is installed in the CoroutineScope of the Store. All uncaught exceptions occurring in the reducer and effects are passed to this handler. The default is ThrowingExceptionHandler which rethrows all received exceptions.

parentJob

An optional Job that, when given, is used as the parent for the Job the Stores CoroutineScope uses. When the parent Job is canceled, then the Stores CoroutineScope is canceled together with all its running Effects.