earroyoron
01/05/2021, 1:40 PMState
I have an object (Customer
) that has his current status as a enum val , I wanna model the posible change from a state to next (as in a state machine pending->...-> review —> onaboarded) and I think using this type is the right way but can’t find a good examplesimon.vergauwen
01/06/2021, 8:24 AMIndexedState
like 3 years ago, but there were some issues at the time with the Compiler. It would probably be possible today, but I haven't gone back to it due to other priorities. There is still a outdated branch of it 😅 https://github.com/arrow-kt/arrow-core/tree/simon-indexedstatetsimon.vergauwen
01/06/2021, 8:28 AMatomic
or Atomic
together with a sealed class
.
• https://github.com/arrow-kt/arrow-fx/blob/master/arrow-fx-coroutines/src/main/kotlin/arrow/fx/coroutines/CircuitBreaker.kt#L14
• https://github.com/arrow-kt/arrow-fx/blob/master/arrow-fx-coroutines/src/main/kotlin/arrow/fx/coroutines/Semaphore.kt#L270Oliver Eisenbarth
01/06/2021, 10:18 PMearroyoron
01/06/2021, 10:32 PMdata class Customer(val status: CustomerStatus)
enum class CustomerStatus{INIT, PENDING, ONBOARDED}
fun Customer.onBoard(): Either<TransitionError,Customer> {
// will check invariants and change Customer to status=ONBOARDED
}
Thanks a lot!Oliver Eisenbarth
01/09/2021, 1:16 PM