ColdStateFlowRepo

constructor(coroutineContext: CoroutineContext = Dispatchers.Main.immediate, firstState: () -> State, initChangeState: suspend (State) -> suspend () -> State, deinitChangeState: suspend (State) -> suspend () -> State)

Constructor

Parameters

coroutineContext

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.

firstState

Creates the first State when observation first takes place.

initChangeState

method called when the repo transitions from no subscriptions to being subscribed to. Contains the last known State and should result in a state transition.

deinitChangeState

method called when the repo transitions from being subscribed to to no subscriptions. Contains the last known State and should result in a state transition.


constructor(coroutineContext: CoroutineContext = Dispatchers.Main.immediate, init: suspend (ColdStateFlowRepo<State>) -> State, deinit: suspend (ColdStateFlowRepo<State>) -> State?, firstState: () -> State)

Constructor

Parameters

coroutineContext

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.

init

method called when the repo transitions from no subscriptions to being subscribed to. Contains a reference to the ColdStateFlowRepo and should result in a State to transition to.

deinit

method called when the repo transitions from being subscribed to to no subscriptions. Contains a reference to the ColdStateFlowRepo and should result in a State to transition to.

firstState

Creates the first State when observation first takes place.


constructor(coroutineContext: CoroutineContext = Dispatchers.Main.immediate, initChangeStateWithRepo: suspend (State, ColdStateFlowRepo<State>) -> suspend () -> State, deinitChangeStateWithRepo: suspend (State, ColdStateFlowRepo<State>) -> suspend () -> State?, firstState: () -> State)

Parameters

State

the type of KalugaState represented by this repo.

coroutineContext

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.

initChangeStateWithRepo

method called when the repo transitions from no subscriptions to being subscribed to. Contains the last known State and provides a reference to this ColdStateFlowRepo, and should result in a state transition.

deinitChangeStateWithRepo

method called when the repo transitions from being subscribed to to no subscriptions. Contains the last known State and provides a reference to this ColdStateFlowRepo, and allows to transition into a deinitialized state.

firstState

Creates the first State when observation first takes place.