https://kotlinlang.org logo
#orbit-mvi
Title
# orbit-mvi
j

Jacob Rhoda

11/17/2023, 9:00 PM
Does anyone have any tips/tricks for reducing the boilerplate needed to update the state of a basic property? Right now, you have to add something to your state and add a method. It would be nice if you could add an annotation or something that would generate that boilerplate for you automatically.
Copy code
data class MyState(
  val myProperty: String?
)
enum class MySideEffect
class MyViewModel(): ViewModel(), ContainerHost<MyState, MySideEffect> {
  override val container: Container<MyState, MySideEffect> = container(MyState(""))

  fun updateMyProperty(newValue: String?) = intent { reduce { state.copy(myProperty=newValue) } }
}