BaseHotStateRepo
A Hot StateRepo, using a MutableSharedFlow as it's backing implementation.
The repo will get initialized when the state is first read and remain initialized after.
Be aware an initialization can take place if state is read, for example by useState or takeAndChangeState, without actual collection events occurring. However a SharedFlow without a replay buffer might trigger a collection to get the initial state if no explicit state is provided
Parameters
the type of KalugaState represented by this repo.
the type of MutableSharedFlow the state will be collected in.
the CoroutineContext used to create a coroutine scope for this state machine. Make sure that if you pass a coroutine context that has sequential execution if you do not want simultaneous state changes. The default Main dispatcher meets these criteria.
Inheritors
Properties
Functions
Collects all elements not implementing SpecialFlowValue.NotImportant from a Flow.
Collects all elements not implementing SpecialFlowValue.NotImportant from a Flow up to the first SpecialFlowValue.Last received.
Collects all elements from a Flow up to the first SpecialFlowValue.Last received.
Filters out all values marked as SpecialFlowValue.NotImportant from a given Flow
Returns first element that is instance of specific type parameter R, or null
if not found
Gets the initial value of the repo
Launches in a given CoroutineContext to change from the current State to a new State. This operation ensures atomic state changes.
Launches in a given CoroutineContext and calls action on the current State. The state is guaranteed not to change during the execution of action. This operation ensures atomic state observations, so the state will not change while the action is being executed.
Changes from the current State to a new State. This operation ensures atomic state changes. The new state is determined by an action, which takes the current State upon starting the state transition and provides a deferred state creation. You are strongly encouraged to use the State provided by the action to determine the new state, to ensure no illegal state transitions occur, as the state may have changed between calling doTakeAndChangeState and the execution of action. If the action returns KalugaState.remain no state transition will occur. Since this operation is atomic, the action should not directly call doTakeAndChangeState itself. If required to do this, handle the additional transition in a separate coroutine.
Transforms a Flow to emit only up to the first SpecialFlowValue.Last received.